- Timestamp:
- 06/28/13 11:56:03 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
java/main/src/main/java/com/framsticks/params/FramsClass.java
r86 r87 8 8 9 9 import javax.annotation.Nonnull; 10 import javax.annotation.concurrent.Immutable; 11 12 import org.apache.log4j.Logger; 10 13 11 14 /** … … 21 24 * @author Piotr Sniegowski 22 25 */ 26 @Immutable 23 27 @FramsClassAnnotation(id = "class", name = "class") 24 28 public final class FramsClass { 25 29 26 /** The offset of the parameter (applied for newly added parameter). */ 27 protected int fieldsNumber; 30 private final static Logger log = Logger.getLogger(FramsClass.class); 28 31 29 /** The groups. */ 30 protected List<Group> groups = new ArrayList<Group>(); 32 protected final String id; 33 34 protected final String name; 35 36 protected final String description; 37 38 protected final List<Group> groups; 39 40 /** The param list (for accessing parameters by offset in O(1) time. */ 41 protected final List<Param> paramList; 31 42 32 43 /** … … 36 47 protected Map<String, Param> paramEntryMap = new LinkedHashMap<String, Param>(); 37 48 38 /** The param list (for accessing parameters by offset in O(1) time. */ 39 protected List<Param> paramList = new ArrayList<Param>(); 40 41 /** The param getId map (for fast lookup of offset based on name */ 42 protected Map<String, Integer> paramIdMap = new HashMap<String, Integer>(); 43 44 protected String id; 45 46 protected String name; 47 48 protected String description; 49 // /** The param getId map (for fast lookup of offset based on name */ 50 // protected Map<String, Integer> paramIdMap = new HashMap<String, Integer>(); 49 51 50 52 public Collection<Param> getParamEntries() { … … 52 54 } 53 55 54 public FramsClass( ) {56 public FramsClass(String id, String name, String description, List<Param> params, List<Group> groups) { 55 57 56 } 58 this.id = id; 59 this.name = name; 60 this.description = description; 61 this.groups = groups; 62 this.paramList = params; 57 63 58 public FramsClass(String id, String name, String description) { 59 this.setId(id); 60 this.setName(name); 61 this.setDescription(description); 62 } 64 for (Param param : params) { 65 paramEntryMap.put(param.getId(), param); 66 try { 67 Group group = groups.get(param.getGroup()); 68 if (group != null) { 69 group.addProperty(param); 70 } 71 } catch (IndexOutOfBoundsException ignored) { 63 72 64 /**65 * Adds new param entry.66 *67 * @param param68 * the new param entry69 */70 public FramsClass append(Param param) {71 // if (param.hasFlag(Flags.USERHIDDEN)) {72 // return this;73 // }74 paramEntryMap.put(param.getId(), param);75 //paramEntryMap.put(param.getInternalId(), param);76 paramList.add(param);77 try {78 Group group = groups.get(param.getGroup());79 if (group != null) {80 group.addProperty(param);81 73 } 82 } catch (IndexOutOfBoundsException ignored) {83 84 74 } 85 75 86 return this; 87 } 76 log.trace("created framsclass " + this); 88 77 89 public FramsClass append(ParamBuilder builder) {90 return append(builder.finish());91 }92 93 /**94 * Adds new group.95 */96 public FramsClass appendGroup(Group group) {97 groups.add(group);98 return this;99 78 } 100 79 … … 206 185 @Override 207 186 public String toString() { 208 return id ;187 return id + "(" + name + ")"; 209 188 } 210 189 211 @ParamAnnotation 212 public void setId(String id) { 213 this.id = id; 214 } 215 216 @ParamAnnotation 217 public void setName(String name) { 218 this.name = name; 219 } 220 221 @ParamAnnotation(id = "desc") 222 public void setDescription(String description) { 223 this.description = description; 190 public static FramsClassBuilder build() { 191 return new FramsClassBuilder(); 224 192 } 225 193 }
Note: See TracChangeset
for help on using the changeset viewer.