001/* -*- mode: Java; c-basic-offset: 2; indent-tabs-mode: nil; coding: utf-8-unix -*- 002 * 003 * Copyright © 2023–2024 microBean™. 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with 006 * the License. You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 011 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 012 * specific language governing permissions and limitations under the License. 013 */ 014package org.microbean.bean; 015 016public class ReductionException extends BeanException { 017 018 private static final long serialVersionUID = 1L; 019 020 private final transient Object criteria; 021 022 public ReductionException() { 023 super(); 024 this.criteria = null; 025 } 026 027 public ReductionException(final Object criteria) { 028 super(); 029 this.criteria = criteria; 030 } 031 032 public ReductionException(final String message) { 033 super(message); 034 this.criteria = null; 035 } 036 037 public ReductionException(final Object criteria, 038 final String message) { 039 super(message); 040 this.criteria = criteria; 041 } 042 043 public ReductionException(final Throwable cause) { 044 super(cause); 045 this.criteria = null; 046 } 047 048 public ReductionException(final Object criteria, 049 final Throwable cause) { 050 super(cause); 051 this.criteria = criteria; 052 } 053 054 public ReductionException(final String message, 055 final Throwable cause) { 056 super(message, cause); 057 this.criteria = null; 058 } 059 060 public ReductionException(final Object criteria, 061 final String message, 062 final Throwable cause) { 063 super(message, cause); 064 this.criteria = criteria; 065 } 066 067 public final Object criteria() { 068 return this.criteria; 069 } 070 071 @Override 072 public String toString() { 073 final Object criteria = this.criteria(); 074 if (criteria == null) { 075 return super.toString(); 076 } else if (this.getLocalizedMessage() == null) { 077 return super.toString() + ": criteria: " + criteria; 078 } else { 079 return super.toString() + "; criteria: " + criteria; 080 } 081 } 082 083}