001// ______________________________________________________
002// Generated by codegen - https://gitee.com/l0km/codegen 
003// template: decorator/decorator.class.vm
004// ______________________________________________________
005package net.gdface.sdk;
006import java.util.List;
007import java.util.Map;
008import net.gdface.image.ImageErrorException;
009import net.gdface.image.MatType;
010/**
011 * decorator pattern 装饰者模式实现{@link FaceApi}接口<br>
012 * 转发所有{@link FaceApi}接口方法到{@link #delegate()}指定的实例,<br>
013 * unchecked后缀的方法将所有显式申明的异常封装到{@link RuntimeException}抛出<br>
014 * 计算机生成代码(generated by automated tools DecoratorGenerator @author guyadong)<br>
015 * @author guyadong
016 *
017 */
018public class FaceApiDecorator implements FaceApi{
019    private final FaceApi delegate;
020    
021    public FaceApiDecorator(FaceApi delegate) {
022        super();
023        if(null == delegate){
024            throw new NullPointerException("delegate is null");
025        }
026        this.delegate = delegate;
027    }
028    /**
029     * 将 {@code FaceApi} 对象封装为 FaceApiDecorator 实例<br>
030     * 如果 {@code FaceApi} 已经是 FaceApiDecorator 则返回 FaceApi}
031     * @param instance
032     * @return FaceApiDecorator 实例
033     */
034    public static final FaceApiDecorator makeDecorator(FaceApi instance){
035        if(instance instanceof FaceApiDecorator){
036            return (FaceApiDecorator)instance;
037        }
038        return new FaceApiDecorator(instance);
039    }
040
041    /**
042     * @return FaceApi 返回被装饰的{@link FaceApi}实例
043     */
044    public FaceApi delegate() {
045        return delegate;
046    }    
047
048    @Override
049    public double compare2Face (byte[] imgData1,CodeInfo facePos1,byte[] imgData2,CodeInfo facePos2) throws ImageErrorException,NotFaceDetectedException{
050        return delegate().compare2Face(imgData1,facePos1,imgData2,facePos2);
051    }
052
053    /**
054     * {@link FaceApi#compare2Face(byte[],CodeInfo,byte[],CodeInfo)}对应的unchecked方法,
055     * 所有显式申明的异常都被封装到{@link RuntimeException}抛出<br>
056     * @param imgData1 imgData1
057     * @param facePos1 facePos1
058     * @param imgData2 imgData2
059     * @param facePos2 facePos2
060     * @return double
061     */
062    public double compare2FaceUnchecked (byte[] imgData1,CodeInfo facePos1,byte[] imgData2,CodeInfo facePos2) {
063        try{
064            return delegate().compare2Face(imgData1,facePos1,imgData2,facePos2);
065        } catch(RuntimeException e){
066            throw e;
067        } catch(Exception e){
068            throw new RuntimeException(e);
069        }
070    }
071
072    @Override
073    public double compareCode (byte[] code1,byte[] code2) {
074        return delegate().compareCode(code1,code2);
075    }
076
077    @Override
078    public double[] compareCodes (byte[] code1,CodeInfo[] codes) {
079        return delegate().compareCodes(code1,codes);
080    }
081
082    @Override
083    public CompareResult compareFaces (byte[] code,byte[] imgData,int faceNum) throws ImageErrorException,NotFaceDetectedException{
084        return delegate().compareFaces(code,imgData,faceNum);
085    }
086
087    /**
088     * {@link FaceApi#compareFaces(byte[],byte[],int)}对应的unchecked方法,
089     * 所有显式申明的异常都被封装到{@link RuntimeException}抛出<br>
090     * @param code code
091     * @param imgData imgData
092     * @param faceNum faceNum
093     * @return CompareResult
094     */
095    public CompareResult compareFacesUnchecked (byte[] code,byte[] imgData,int faceNum) {
096        try{
097            return delegate().compareFaces(code,imgData,faceNum);
098        } catch(RuntimeException e){
099            throw e;
100        } catch(Exception e){
101            throw new RuntimeException(e);
102        }
103    }
104
105    @Override
106    public List<Double> compareFeatures (byte[] code1,List<byte[]> codes) {
107        return delegate().compareFeatures(code1,codes);
108    }
109
110    @Override
111    public double detectAndCompare2Face (byte[] imgData1,FRect detectRect1,byte[] imgData2,FRect detectRect2) throws ImageErrorException,NotFaceDetectedException{
112        return delegate().detectAndCompare2Face(imgData1,detectRect1,imgData2,detectRect2);
113    }
114
115    /**
116     * {@link FaceApi#detectAndCompare2Face(byte[],FRect,byte[],FRect)}对应的unchecked方法,
117     * 所有显式申明的异常都被封装到{@link RuntimeException}抛出<br>
118     * @param imgData1 imgData1
119     * @param detectRect1 detectRect1
120     * @param imgData2 imgData2
121     * @param detectRect2 detectRect2
122     * @return double
123     */
124    public double detectAndCompare2FaceUnchecked (byte[] imgData1,FRect detectRect1,byte[] imgData2,FRect detectRect2) {
125        try{
126            return delegate().detectAndCompare2Face(imgData1,detectRect1,imgData2,detectRect2);
127        } catch(RuntimeException e){
128            throw e;
129        } catch(Exception e){
130            throw new RuntimeException(e);
131        }
132    }
133
134    @Override
135    public CodeInfo[] detectAndGetCodeInfo (byte[] imgData,int faceNum) throws ImageErrorException,NotFaceDetectedException{
136        return delegate().detectAndGetCodeInfo(imgData,faceNum);
137    }
138
139    /**
140     * {@link FaceApi#detectAndGetCodeInfo(byte[],int)}对应的unchecked方法,
141     * 所有显式申明的异常都被封装到{@link RuntimeException}抛出<br>
142     * @param imgData imgData
143     * @param faceNum faceNum
144     * @return CodeInfo[]
145     */
146    public CodeInfo[] detectAndGetCodeInfoUnchecked (byte[] imgData,int faceNum) {
147        try{
148            return delegate().detectAndGetCodeInfo(imgData,faceNum);
149        } catch(RuntimeException e){
150            throw e;
151        } catch(Exception e){
152            throw new RuntimeException(e);
153        }
154    }
155
156    @Override
157    public CodeInfo detectCenterFace (byte[] imgData) throws ImageErrorException,NotFaceDetectedException{
158        return delegate().detectCenterFace(imgData);
159    }
160
161    /**
162     * {@link FaceApi#detectCenterFace(byte[])}对应的unchecked方法,
163     * 所有显式申明的异常都被封装到{@link RuntimeException}抛出<br>
164     * @param imgData imgData
165     * @return CodeInfo
166     */
167    public CodeInfo detectCenterFaceUnchecked (byte[] imgData) {
168        try{
169            return delegate().detectCenterFace(imgData);
170        } catch(RuntimeException e){
171            throw e;
172        } catch(Exception e){
173            throw new RuntimeException(e);
174        }
175    }
176
177    @Override
178    public CodeInfo[] detectFace (byte[] imgData) throws ImageErrorException{
179        return delegate().detectFace(imgData);
180    }
181
182    /**
183     * {@link FaceApi#detectFace(byte[])}对应的unchecked方法,
184     * 所有显式申明的异常都被封装到{@link RuntimeException}抛出<br>
185     * @param imgData imgData
186     * @return CodeInfo[]
187     */
188    public CodeInfo[] detectFaceUnchecked (byte[] imgData) {
189        try{
190            return delegate().detectFace(imgData);
191        } catch(RuntimeException e){
192            throw e;
193        } catch(Exception e){
194            throw new RuntimeException(e);
195        }
196    }
197
198    @Override
199    public CodeInfo detectMaxFace (byte[] imgData) throws ImageErrorException,NotFaceDetectedException{
200        return delegate().detectMaxFace(imgData);
201    }
202
203    /**
204     * {@link FaceApi#detectMaxFace(byte[])}对应的unchecked方法,
205     * 所有显式申明的异常都被封装到{@link RuntimeException}抛出<br>
206     * @param imgData imgData
207     * @return CodeInfo
208     */
209    public CodeInfo detectMaxFaceUnchecked (byte[] imgData) {
210        try{
211            return delegate().detectMaxFace(imgData);
212        } catch(RuntimeException e){
213            throw e;
214        } catch(Exception e){
215            throw new RuntimeException(e);
216        }
217    }
218
219    @Override
220    public CodeInfo[] getCodeInfo (byte[] imgData,int faceNum,CodeInfo[] facePos) throws NotFaceDetectedException{
221        return delegate().getCodeInfo(imgData,faceNum,facePos);
222    }
223
224    /**
225     * {@link FaceApi#getCodeInfo(byte[],int,net.gdface.sdk.CodeInfo[])}对应的unchecked方法,
226     * 所有显式申明的异常都被封装到{@link RuntimeException}抛出<br>
227     * @param imgData imgData
228     * @param faceNum faceNum
229     * @param facePos facePos
230     * @return CodeInfo[]
231     */
232    public CodeInfo[] getCodeInfoUnchecked (byte[] imgData,int faceNum,CodeInfo[] facePos) {
233        try{
234            return delegate().getCodeInfo(imgData,faceNum,facePos);
235        } catch(RuntimeException e){
236            throw e;
237        } catch(Exception e){
238            throw new RuntimeException(e);
239        }
240    }
241
242    @Override
243    public CodeInfo getCodeInfo (byte[] imgData,CodeInfo facePos) {
244        return delegate().getCodeInfo(imgData,facePos);
245    }
246
247    @Override
248    public byte[] getFeature (Map<java.nio.ByteBuffer, CodeInfo> faces) throws NotFaceDetectedException{
249        return delegate().getFeature(faces);
250    }
251
252    /**
253     * {@link FaceApi#getFeature(Map)}对应的unchecked方法,
254     * 所有显式申明的异常都被封装到{@link RuntimeException}抛出<br>
255     * @param faces faces
256     * @return byte[]
257     */
258    public byte[] getFeatureUnchecked (Map<java.nio.ByteBuffer, CodeInfo> faces) {
259        try{
260            return delegate().getFeature(faces);
261        } catch(RuntimeException e){
262            throw e;
263        } catch(Exception e){
264            throw new RuntimeException(e);
265        }
266    }
267
268    @Override
269    public boolean hasFace (byte[] imgData) throws ImageErrorException{
270        return delegate().hasFace(imgData);
271    }
272
273    /**
274     * {@link FaceApi#hasFace(byte[])}对应的unchecked方法,
275     * 所有显式申明的异常都被封装到{@link RuntimeException}抛出<br>
276     * @param imgData imgData
277     * @return boolean
278     */
279    public boolean hasFaceUnchecked (byte[] imgData) {
280        try{
281            return delegate().hasFace(imgData);
282        } catch(RuntimeException e){
283            throw e;
284        } catch(Exception e){
285            throw new RuntimeException(e);
286        }
287    }
288
289    @Override
290    public boolean isLocal () {
291        return delegate().isLocal();
292    }
293
294    @Override
295    public CodeInfo[] matDetectAndGetCodeInfo (MatType matType,byte[] matData,int width,int height,int faceNum) throws NotFaceDetectedException{
296        return delegate().matDetectAndGetCodeInfo(matType,matData,width,height,faceNum);
297    }
298
299    /**
300     * {@link FaceApi#matDetectAndGetCodeInfo(MatType,byte[],int,int,int)}对应的unchecked方法,
301     * 所有显式申明的异常都被封装到{@link RuntimeException}抛出<br>
302     * @param matType matType
303     * @param matData matData
304     * @param width width
305     * @param height height
306     * @param faceNum faceNum
307     * @return CodeInfo[]
308     */
309    public CodeInfo[] matDetectAndGetCodeInfoUnchecked (MatType matType,byte[] matData,int width,int height,int faceNum) {
310        try{
311            return delegate().matDetectAndGetCodeInfo(matType,matData,width,height,faceNum);
312        } catch(RuntimeException e){
313            throw e;
314        } catch(Exception e){
315            throw new RuntimeException(e);
316        }
317    }
318
319    @Override
320    public CodeInfo[] matDetectFace (MatType matType,byte[] matData,int width,int height) {
321        return delegate().matDetectFace(matType,matData,width,height);
322    }
323
324    @Override
325    public CodeInfo matDetectMaxFace (MatType matType,byte[] matData,int width,int height) throws NotFaceDetectedException{
326        return delegate().matDetectMaxFace(matType,matData,width,height);
327    }
328
329    /**
330     * {@link FaceApi#matDetectMaxFace(MatType,byte[],int,int)}对应的unchecked方法,
331     * 所有显式申明的异常都被封装到{@link RuntimeException}抛出<br>
332     * @param matType matType
333     * @param matData matData
334     * @param width width
335     * @param height height
336     * @return CodeInfo
337     */
338    public CodeInfo matDetectMaxFaceUnchecked (MatType matType,byte[] matData,int width,int height) {
339        try{
340            return delegate().matDetectMaxFace(matType,matData,width,height);
341        } catch(RuntimeException e){
342            throw e;
343        } catch(Exception e){
344            throw new RuntimeException(e);
345        }
346    }
347
348    @Override
349    public CodeInfo[] matGetCodeInfo (MatType matType,byte[] matData,int width,int height,int facenum,CodeInfo[] facePos) throws NotFaceDetectedException{
350        return delegate().matGetCodeInfo(matType,matData,width,height,facenum,facePos);
351    }
352
353    /**
354     * {@link FaceApi#matGetCodeInfo(MatType,byte[],int,int,int,net.gdface.sdk.CodeInfo[])}对应的unchecked方法,
355     * 所有显式申明的异常都被封装到{@link RuntimeException}抛出<br>
356     * @param matType matType
357     * @param matData matData
358     * @param width width
359     * @param height height
360     * @param facenum facenum
361     * @param facePos facePos
362     * @return CodeInfo[]
363     */
364    public CodeInfo[] matGetCodeInfoUnchecked (MatType matType,byte[] matData,int width,int height,int facenum,CodeInfo[] facePos) {
365        try{
366            return delegate().matGetCodeInfo(matType,matData,width,height,facenum,facePos);
367        } catch(RuntimeException e){
368            throw e;
369        } catch(Exception e){
370            throw new RuntimeException(e);
371        }
372    }
373
374    @Override
375    public CodeInfo matGetCodeInfo (MatType matType,byte[] matData,int width,int height,CodeInfo facePos) {
376        return delegate().matGetCodeInfo(matType,matData,width,height,facePos);
377    }
378
379    @Override
380    public boolean matHasFace (MatType matType,byte[] matData,int width,int height) {
381        return delegate().matHasFace(matType,matData,width,height);
382    }
383
384    @Override
385    public FseResult[] matSearchFaces (MatType matType,byte[] matData,int width,int height,CodeInfo facePos,double similarty,int rows) throws ImageErrorException,NotFaceDetectedException{
386        return delegate().matSearchFaces(matType,matData,width,height,facePos,similarty,rows);
387    }
388
389    /**
390     * {@link FaceApi#matSearchFaces(MatType,byte[],int,int,CodeInfo,double,int)}对应的unchecked方法,
391     * 所有显式申明的异常都被封装到{@link RuntimeException}抛出<br>
392     * @param matType matType
393     * @param matData matData
394     * @param width width
395     * @param height height
396     * @param facePos facePos
397     * @param similarty similarty
398     * @param rows rows
399     * @return FseResult[]
400     */
401    public FseResult[] matSearchFacesUnchecked (MatType matType,byte[] matData,int width,int height,CodeInfo facePos,double similarty,int rows) {
402        try{
403            return delegate().matSearchFaces(matType,matData,width,height,facePos,similarty,rows);
404        } catch(RuntimeException e){
405            throw e;
406        } catch(Exception e){
407            throw new RuntimeException(e);
408        }
409    }
410
411    @Override
412    public Boolean matWearMask (MatType matType,byte[] matData,int width,int height,CodeInfo faceInfo) {
413        return delegate().matWearMask(matType,matData,width,height,faceInfo);
414    }
415
416    @Override
417    public Map<String, String> sdkCapacity () {
418        return delegate().sdkCapacity();
419    }
420
421    @Override
422    public FseResult[] searchFaces (byte[] imgData,CodeInfo facePos,double similarty,int rows) throws ImageErrorException,NotFaceDetectedException{
423        return delegate().searchFaces(imgData,facePos,similarty,rows);
424    }
425
426    /**
427     * {@link FaceApi#searchFaces(byte[],CodeInfo,double,int)}对应的unchecked方法,
428     * 所有显式申明的异常都被封装到{@link RuntimeException}抛出<br>
429     * @param imgData imgData
430     * @param facePos facePos
431     * @param similarty similarty
432     * @param rows rows
433     * @return FseResult[]
434     */
435    public FseResult[] searchFacesUnchecked (byte[] imgData,CodeInfo facePos,double similarty,int rows) {
436        try{
437            return delegate().searchFaces(imgData,facePos,similarty,rows);
438        } catch(RuntimeException e){
439            throw e;
440        } catch(Exception e){
441            throw new RuntimeException(e);
442        }
443    }
444
445    @Override
446    public FseResult[] searchFeatures (byte[] feature,double similarty,int rows) {
447        return delegate().searchFeatures(feature,similarty,rows);
448    }
449
450    @Override
451    public Boolean wearMask (byte[] imgData,CodeInfo faceInfo) throws ImageErrorException{
452        return delegate().wearMask(imgData,faceInfo);
453    }
454
455    /**
456     * {@link FaceApi#wearMask(byte[],CodeInfo)}对应的unchecked方法,
457     * 所有显式申明的异常都被封装到{@link RuntimeException}抛出<br>
458     * @param imgData imgData
459     * @param faceInfo faceInfo
460     * @return Boolean
461     */
462    public Boolean wearMaskUnchecked (byte[] imgData,CodeInfo faceInfo) {
463        try{
464            return delegate().wearMask(imgData,faceInfo);
465        } catch(RuntimeException e){
466            throw e;
467        } catch(Exception e){
468            throw new RuntimeException(e);
469        }
470    }
471}