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