- Timestamp:
- 09/10/13 21:11:41 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
java/main/src/main/java/com/framsticks/params/FramsClass.java
r100 r105 3 3 import com.framsticks.params.annotations.FramsClassAnnotation; 4 4 import com.framsticks.params.annotations.ParamAnnotation; 5 import com.framsticks.util.FramsticksException;6 5 import com.framsticks.util.lang.Containers; 7 6 import com.framsticks.util.lang.Strings; … … 10 9 import java.util.*; 11 10 12 import javax.annotation.Nonnull;13 11 import javax.annotation.concurrent.Immutable; 14 12 … … 30 28 @Immutable 31 29 @FramsClassAnnotation(id = "class", name = "class") 32 public class FramsClass {30 public class FramsClass implements ParamCollection { 33 31 34 32 private final static Logger log = LogManager.getLogger(FramsClass.class); … … 55 53 56 54 @ParamAnnotation(id = "props", name = "props") 57 public List<Param> getParam Entries() {55 public List<Param> getParams() { 58 56 return Collections.unmodifiableList(paramList); 59 57 } … … 135 133 } 136 134 137 public @Nonnull <T extends Param> T castedParam(@Nonnull final Param param, @Nonnull final Class<T> type, Object name) {138 if (param == null) {139 // return null;140 throw new FramsticksException().msg("param is missing").arg("name", name).arg("in", this);141 }142 if (!type.isInstance(param)) {143 // return null;144 throw new FramsticksException().msg("wrong type of param").arg("actual", param.getClass()).arg("requested", type).arg("in", this);145 }146 return type.cast(param);147 }148 149 /**150 * Gets the param entry.151 *152 * @param i153 * the offset of parameter154 * @return the param entry155 */156 public @Nonnull <T extends Param> T getParamEntry(final int i, @Nonnull final Class<T> type) {157 return castedParam(getParam(i), type, i);158 }159 160 /**161 * Gets the param entry.162 *163 * @param id164 * the getId of parameter165 * @return the param entry166 */167 public @Nonnull <T extends Param> T getParamEntry(@Nonnull final String id, @Nonnull final Class<T> type) {168 return castedParam(getParam(id), type, id);169 }170 171 135 public Param getParam(int i) { 172 136 if (i < 0 || i >= paramList.size()) {
Note: See TracChangeset
for help on using the changeset viewer.