com.squeakysand.commons.valueobjects.InvalidValueObjectException Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of squeakysand-commons Show documentation
Show all versions of squeakysand-commons Show documentation
Classes, interfaces and enums that assist with everyday Java development tasks.
The newest version!
/*
* Copyright 2010-2012 Craig S. Dickson (http://craigsdickson.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.squeakysand.commons.valueobjects;
/**
* Exception thrown by a service when an invalid ValueObject is passed to it.
*/
public class InvalidValueObjectException extends Exception {
private static final long serialVersionUID = -4986699486275092532L;
private final ValueObject vo;
/**
* Creates a new InvalidValueObjectException object.
*/
public InvalidValueObjectException() {
this(null);
}
/**
* Creates a new InvalidValueObjectException object.
*
* @param vo the object that caused the exception to be thrown.
*/
public InvalidValueObjectException(ValueObject vo) {
super();
if (vo != null) {
this.vo = (ValueObject) vo.clone();
} else {
this.vo = null;
}
}
/**
* Creates a new $class.name$ object.
*
* @param vo the object that caused the exception to be thrown.
* @param cause the underlying exception to propogate.
*/
public InvalidValueObjectException(ValueObject vo, Throwable cause) {
super(cause);
if (vo != null) {
this.vo = (ValueObject) vo.clone();
} else {
this.vo = null;
}
}
/**
* Accessor for the object that caused the exception.
*
* @return the object that caused the exception.
*/
public ValueObject getValueObject() {
return (ValueObject) vo.clone();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy