001// ______________________________________________________ 002// Generated by codegen - https://gitee.com/l0km/codegen 003// template: thrift/client/perstruct/exception.decorator.class.vm 004// ______________________________________________________ 005package net.gdface.image.decorator.client; 006import net.gdface.thrift.ThriftDecorator; 007import net.gdface.thrift.exception.BaseServiceException; 008 009import java.io.PrintStream; 010import java.io.PrintWriter; 011import com.facebook.swift.codec.ThriftStruct; 012import static com.google.common.base.Preconditions.checkNotNull; 013 014/** 015 * decorator pattern 装饰者模式代理{@link net.gdface.image.ImageErrorException}<br> 016 * 代理对象必须有默认构造方法,String参数构造方法可选,必须是普通类型,不可以有@ThriftStruct注释<br> 017 * 转发所有{@link net.gdface.image.ImageErrorException}get/set方法到{@link #delegate()}指定的实例,<br> 018 * 计算机生成代码(generated by automated tools ThriftServiceDecoratorGenerator @author guyadong)<br> 019 * @author guyadong 020 * 021 */ 022@ThriftStruct 023public final class ImageErrorException extends BaseServiceException 024 implements ThriftDecorator<net.gdface.image.ImageErrorException> { 025 private static final long serialVersionUID = 1L; 026 private final net.gdface.image.ImageErrorException delegate; 027 028 public ImageErrorException(){ 029 this(new net.gdface.image.ImageErrorException()); 030 } 031 public ImageErrorException(String message){ 032 this(new net.gdface.image.ImageErrorException(message)); 033 } 034 public ImageErrorException(net.gdface.image.ImageErrorException delegate) { 035 super(checkNotNull(delegate,"delegate is null").getMessage(),delegate.getCause()); 036 // 检查被装饰类是否有@ThriftStruct注释 037 if(delegate.getClass().isAnnotationPresent(ThriftStruct.class)){ 038 throw new IllegalArgumentException( 039 String.format("NOT ALLOW %s have @ThriftStruct annotation",delegate.getClass().getName())); 040 } 041 this.delegate = delegate; 042 } 043 /** 044 * @return 返回被装饰的{@link net.gdface.image.ImageErrorException}实例 045 */ 046 @Override 047 public net.gdface.image.ImageErrorException delegate() { 048 return delegate; 049 } 050 @Override 051 public void printStackTrace() { 052 delegate().printStackTrace(); 053 } 054 @Override 055 public void printStackTrace(PrintStream s) { 056 delegate().printStackTrace(s); 057 } 058 @Override 059 public void printStackTrace(PrintWriter s) { 060 delegate().printStackTrace(s); 061 } 062 @Override 063 public StackTraceElement[] getStackTrace() { 064 return delegate().getStackTrace(); 065 } 066 @Override 067 public Throwable initCause(Throwable cause) { 068 return delegate().initCause(cause); 069 } 070 @Override 071 public int hashCode() { 072 return delegate().hashCode(); 073 } 074 @Override 075 public boolean equals(Object obj) { 076 return delegate().equals(obj); 077 } 078 @Override 079 public String toString() { 080 return delegate().toString(); 081 } 082}