Ignore:
Timestamp:
06/28/13 11:56:03 (11 years ago)
Author:
psniegowski
Message:

HIGHLIGHTS:

  • FramsClass? and contained Param are now immutable classes (like String),

which allows to refer to them concurrently without synchronization
(which for example in turn simplifies GUI management)

  • also make Path immutable (which was earlier only assumed)
  • add global cache for FramsClasses? created solely and automatically

on base of Java classes.

representations basing on given FramsClass?

  • above changes greatly improved GUI responsivness during browsing
  • furtherly improve Param class hierarchy
  • allow to inject actions on state changes into MultiParamLoader?
  • add more tests

CHANGELOG:

Add StatusListener? to MultiParamLoader?.

Minor refactorization in MultiParamLoader?.

First step with auto append.

Add SchemaTest?.

Improve Registry.

Clean up in Registry.

Work out Registry.

Use annotations for Param.

Fix ListChange?.

Improve fluent interface of the FramsClassBuilder?.

Done caching of ReflectionAccess?.Backend

Fix hashCode of Pair.

A step on a way to cache ReflectionAccess?.Backend

Make SimpleAbstractAccess?.framsClass a final field.

Add static cache for FramsClasses? based on java.

Only classes created strictly and automatically
based on java classes are using this cache.

Make all Params immutable.

Many improvement to make Param immutable.

Make PrimitiveParam? generic type.

Several changes to make Param immutable.

Make FramsClass? immutable.

Another improvement to Path immutability.

Several improvements to Path.

Improve PathTest?.

Configurarable MutabilityDetector?.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • java/main/src/main/java/com/framsticks/params/FramsClass.java

    r86 r87  
    88
    99import javax.annotation.Nonnull;
     10import javax.annotation.concurrent.Immutable;
     11
     12import org.apache.log4j.Logger;
    1013
    1114/**
     
    2124 * @author Piotr Sniegowski
    2225 */
     26@Immutable
    2327@FramsClassAnnotation(id = "class", name = "class")
    2428public final class FramsClass {
    2529
    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);
    2831
    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;
    3142
    3243        /**
     
    3647        protected Map<String, Param> paramEntryMap = new LinkedHashMap<String, Param>();
    3748
    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>();
    4951
    5052        public Collection<Param> getParamEntries() {
     
    5254        }
    5355
    54         public FramsClass() {
     56        public FramsClass(String id, String name, String description, List<Param> params, List<Group> groups) {
    5557
    56         }
     58                this.id = id;
     59                this.name = name;
     60                this.description = description;
     61                this.groups = groups;
     62                this.paramList = params;
    5763
    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) {
    6372
    64         /**
    65          * Adds new param entry.
    66          *
    67          * @param param
    68          *            the new param entry
    69          */
    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);
    8173                        }
    82                 } catch (IndexOutOfBoundsException ignored) {
    83 
    8474                }
    8575
    86                 return this;
    87         }
     76                log.trace("created framsclass " + this);
    8877
    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;
    9978        }
    10079
     
    206185        @Override
    207186        public String toString() {
    208                 return id;
     187                return id + "(" + name + ")";
    209188        }
    210189
    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();
    224192        }
    225193}
Note: See TracChangeset for help on using the changeset viewer.