Ignore:
Timestamp:
06/26/13 13:27:31 (11 years ago)
Author:
psniegowski
Message:

HIGHLIGHTS:

  • use java annotations to mark classes and fields to be used when:
    • using java classes with ReflectionAccess? to represent remote objects with FramsClass? description found by "info ..." requests
    • to build up FramsClass? representation of objects not present at remote server
  • allow using primitive types (instead of wraping counterparts) in reflected classes
  • rework FramsClass? creation process (add FramsClassBuilder?)
  • add more tests

CHANGELOG:
Prepare model.World class.

Minor change.

Use primitive types for Genotype and Creature classes.

Use primitive types in model.Neuro* classes.

Use primitive types in model.Joint* classes.

Use primitive types in model.Part* classes.

Fix primitive values.

Extract FramsClassBuilder?.

Add tests of Model classes.

More fixes.

Refactorize out ParamCandidate?.

Several fixes.

Fix all regressions after introducing annotations.

Use annotations throughout the project.

Add exception classes.

Improve creation of FramsClass?.

More changes.

Many changes regarding annotations.

Annotate classes in com.framsticks.model package.

Remove manual FramsClass? constructor.

Construct FramsClass? for Creature. Add test.

Add default values to the ParamAnnotation?.

Add ParamBuilderTest? and ParamAnnotation?.

Add FramsClassAnnotation?.

File:
1 edited

Legend:

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

    r85 r86  
    11package com.framsticks.params;
    22
     3import com.framsticks.params.annotations.FramsClassAnnotation;
     4import com.framsticks.params.annotations.ParamAnnotation;
    35import com.framsticks.params.types.*;
    46import com.framsticks.util.lang.Numbers;
     
    810import java.util.ArrayList;
    911import java.util.Arrays;
     12
    1013
    1114/**
     
    1821 */
    1922
     23@FramsClassAnnotation(name = "prop", id = "prop")
    2024public class ParamBuilder {
    2125        private final static Logger log = Logger.getLogger(ParamBuilder.class.getName());
     
    2832        private static final String FLAGS_FIELD = "flags";
    2933
    30         /** The parameter getId. */
     34        /** The parameter id. */
    3135        private String id;
    3236
    3337        /**
    34          * The parameter internal getId. It's set by a user to use user's own getId in
     38         * The parameter internal id. It's set by a user to use user's own id in
    3539         * code
    3640         */
     
    4044        private Integer group = 0;
    4145
    42         /** The getFlags stored as a bit sum. */
     46        /** The flags stored as a bit sum. */
    4347        private Integer flags = 0;
    4448
    45         /** The parameter getName. */
     49        /** The parameter name. */
    4650        private String name;
    4751
    48         /** The getHelp (description) concerning parameter. */
     52        /** The help (description) concerning parameter. */
    4953        private String help;
    5054
    51         /** The getType of parameter. */
     55        /** The type of parameter. */
    5256        private Class<? extends Param> paramType;
    5357
    5458        private Param param;
    5559        private PrimitiveParam primitiveParam;
    56 
    57         ParamBuilder() {
     60        private String typeString;
     61
     62        public ParamBuilder() {
    5863        }
    5964
     
    7681        }
    7782
     83        @ParamAnnotation
    7884        public ParamBuilder id(String id) {
    7985                this.id = id;
     
    8793                        primitiveParam = (PrimitiveParam) param;
    8894                }
     95                typeString = param.getFramsTypeName();
    8996                return this;
    9097        }
    9198
    9299        public <T extends Param> ParamBuilder type(Class<T> type) {
     100                assert type != null;
    93101                try {
    94102                        return internalSetType(type, type.newInstance());
     
    104112
    105113
     114        /**
     115         * @return the id
     116         */
     117        @ParamAnnotation
     118        public String getId() {
     119                return id;
     120        }
     121
    106122        public ParamBuilder setInternalId(String internalId) {
    107123                this.internalId = internalId;
     
    109125        }
    110126
     127        @ParamAnnotation
    111128        public ParamBuilder group(Integer group) {
    112129                this.group = group;
     
    114131        }
    115132
     133        @ParamAnnotation
    116134        public ParamBuilder flags(Integer flags) {
    117135                this.flags = flags;
     
    119137        }
    120138
     139        @ParamAnnotation
    121140        public ParamBuilder name(String name) {
    122141                this.name = name;
     
    143162        }
    144163
     164        @ParamAnnotation
    145165        public ParamBuilder type(String type) {
     166                typeString = type;
    146167
    147168                log.trace("parsing type: " + type);
     
    233254        }
    234255
     256        @ParamAnnotation
    235257        public ParamBuilder help(String help) {
    236258                this.help = help;
    237259                return this;
     260        }
     261
     262        /**
     263         * @return the group
     264         */
     265        @ParamAnnotation
     266        public Integer getGroup() {
     267                return group;
     268        }
     269
     270        /**
     271         * @return the flags
     272         */
     273        @ParamAnnotation
     274        public Integer getFlags() {
     275                return flags;
     276        }
     277
     278        /**
     279         * @return the name
     280         */
     281        @ParamAnnotation
     282        public String getName() {
     283                return name;
     284        }
     285
     286        /**
     287         * @return the help
     288         */
     289        @ParamAnnotation
     290        public String getHelp() {
     291                return help;
     292        }
     293
     294        @ParamAnnotation
     295        public String getType() {
     296                return typeString;
    238297        }
    239298
     
    328387
    329388
    330         public static FramsClass getFramsClass() {
    331                 return new FramsClass("prop", "prop", null)
    332                         .append(Param.build().id("name").name("Name").type(StringParam.class))
    333                         .append(Param.build().id("id").name("Id").type(StringParam.class))
    334                         .append(Param.build().id("type").name("Type").type(StringParam.class))
    335                         .append(Param.build().id("help").name("Help").type(StringParam.class))
    336                         .append(Param.build().id("group").name("Group").type(DecimalParam.class))
    337                         .append(Param.build().id("flags").name("Flags").type(DecimalParam.class));
    338         }
    339389
    340390}
Note: See TracChangeset for help on using the changeset viewer.