source: java/main/src/main/java/com/framsticks/params/Param.java @ 193

Last change on this file since 193 was 193, checked in by Maciej Komosinski, 10 years ago

Set svn:eol-style native for all textual files

  • Property svn:eol-style set to native
File size: 2.1 KB
RevLine 
[77]1package com.framsticks.params;
2
[86]3
[87]4import javax.annotation.concurrent.Immutable;
[77]5
[87]6import com.framsticks.params.annotations.FramsClassAnnotation;
7import com.framsticks.params.annotations.ParamAnnotation;
8
[77]9/**
10 * Based on c++ struct ParamEntry located in cpp/gdk/param.h
11 * Here  it is a root of Param hierarchy.
12 *
13 * @author Jarek Szymczak <name.surname@gmail.com>, Mateusz Jarus
14 * (please replace name and surname with my personal data)
15 *
16 * @author Piotr Śniegowski
17 */
[87]18@Immutable
[96]19@FramsClassAnnotation(id = "prop", name = "prop", order = {"id", "name", "type", "flags", "help", "group", "extra"})
[77]20public abstract class Param {
21
22        /** The parameter id. */
[87]23        protected final String id;
[77]24
25        /** The parameter name. */
[87]26        protected final String name;
[77]27
28        /** The help (description) concerning parameter. */
[87]29        protected final String help;
[77]30
31        /** The number of group, that parameter belongs to. */
[87]32        protected final Integer group;
[77]33
34        /** The getFlags stored as a bit sum. */
[96]35        protected final int flags;
[77]36
37        /** The variable determining whether the parameter is an extra parameter. */
[96]38        protected final int extra;
[77]39
[87]40        public Param(ParamBuilder builder) {
41                id = builder.getId();
42                name = builder.getName();
43                help = builder.getHelp();
44                group = builder.getGroup();
45                flags = builder.getFlags();
[88]46                extra = builder.getExtra();
[77]47        }
48
[87]49        @ParamAnnotation
[77]50        public String getId() {
51                return id;
52        }
53
[87]54        @ParamAnnotation
[77]55        public String getName() {
56                return name;
57        }
58
[87]59        @ParamAnnotation
[77]60        public String getHelp() {
61                return help;
62        }
63
[87]64        @ParamAnnotation
[77]65        public Integer getGroup() {
66                return group;
67        }
68
[96]69        @ParamAnnotation(def = "0")
[77]70        public Integer getFlags() {
71                return flags;
72        }
73
[96]74        @ParamAnnotation(id = "type")
[84]75        public abstract String getFramsTypeName();
[77]76
[90]77        @ParamAnnotation
[77]78        public Integer getExtra() {
79                return extra;
80        }
81
82        @Override
83        public String toString() {
84                return getId() + ":" + this.getClass().getSimpleName();
85        }
86
87        public boolean hasFlag(int flag) {
[96]88                return (flags & flag) != 0;
[77]89        }
90
[85]91        public static ParamBuilder build() {
92                return new ParamBuilder();
93        }
94
[87]95        public static ParamBuilder build(FramsClassBuilder builder) {
96                return new ParamBuilder(builder);
97        }
98
[77]99}
Note: See TracBrowser for help on using the repository browser.