Skip to content

Package: ImageModelHolder

ImageModelHolder

nameinstructionbranchcomplexitylinemethod
ImageModelHolder()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getNickName()
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
setDefault(Class)
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
setNickName(String)
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
static {...}
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
toString()
M: 39 C: 0
0%
M: 6 C: 0
0%
M: 4 C: 0
0%
M: 9 C: 0
0%
M: 1 C: 0
0%
wrap(ImageModel)
M: 6 C: 9
60%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 2 C: 3
60%
M: 0 C: 1
100%

Coverage

1: /*
2: * *********************************************************************************************************************
3: *
4: * Mistral: open source imaging engine
5: * http://tidalwave.it/projects/mistral
6: *
7: * Copyright (C) 2003 - 2023 by Tidalwave s.a.s. (http://tidalwave.it)
8: *
9: * *********************************************************************************************************************
10: *
11: * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
12: * the License. You may obtain a copy of the License at
13: *
14: * http://www.apache.org/licenses/LICENSE-2.0
15: *
16: * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
17: * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
18: * specific language governing permissions and limitations under the License.
19: *
20: * *********************************************************************************************************************
21: *
22: * git clone https://bitbucket.org/tidalwave/mistral-src
23: * git clone https://github.com/tidalwave-it/mistral-src
24: *
25: * *********************************************************************************************************************
26: */
27: package it.tidalwave.image;
28:
29: import java.io.Serializable;
30:
31: /***********************************************************************************************************************
32: *
33: * @author Fabrizio Giudici
34: *
35: **********************************************************************************************************************/
36: public abstract class ImageModelHolder implements Serializable
37: {
38: private static Class<? extends ImageModelHolder> defaultClass = SerializableImageModelHolder.class;
39:
40: public abstract void set (ImageModel imageModel);
41:
42: public abstract ImageModel get();
43:
44: public static void setDefault (final Class<? extends ImageModelHolder> defaultClass)
45: {
46: ImageModelHolder.defaultClass = defaultClass;
47: }
48:
49: public void setNickName (final String nickName)
50: {
51: get().setNickName(nickName);
52: }
53:
54: public String getNickName()
55: {
56: return get().getNickName();
57: }
58:
59: public static ImageModelHolder wrap (final ImageModel imageModel)
60: {
61: try
62: {
63: // System.err.println("Wrapping ImageModel into a " + defaultClass.getName());
64: final var holder = defaultClass.newInstance();
65: holder.set(imageModel);
66:
67: return holder;
68: }
69: catch (Exception e)
70: {
71: throw new RuntimeException(e);
72: }
73: }
74:
75: @Override
76: public String toString()
77: {
78:
79: final var buffer = new StringBuilder(getClass().getName() + "[");
80: final var model = get();
81:• buffer.append((model != null) ? model.getId() : "null");
82:
83:• if (model != null)
84: {
85: final var nickName = getNickName();
86:
87:• if (nickName != null)
88: {
89: buffer.append(", " + nickName);
90: }
91: }
92:
93: buffer.append("]");
94:
95: return buffer.toString();
96: }
97: }