source: java/main/src/main/java/com/framsticks/util/FramsticksException.java @ 86

Last change on this file since 86 was 86, checked in by psniegowski, 11 years ago

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 size: 1.1 KB
Line 
1package com.framsticks.util;
2
3import java.util.ArrayList;
4import java.util.List;
5
6import com.framsticks.util.lang.Delimeted;
7import com.framsticks.util.lang.Pair;
8
9@SuppressWarnings("serial")
10public class FramsticksException extends RuntimeException {
11
12        protected List<Pair<String, Object>> arguments;
13        protected String message;
14
15        public FramsticksException() {
16                super("framsticks exception");
17        }
18
19        public FramsticksException msg(String message) {
20                this.message = message;
21                return this;
22        }
23
24        public FramsticksException cause(Throwable cause) {
25                initCause(cause);
26                return this;
27        }
28
29        public FramsticksException arg(String header, Object argument) {
30                if (arguments == null) {
31                        arguments = new ArrayList<>();
32                }
33                arguments.add(new Pair<String, Object>(header, argument));
34                return this;
35        }
36
37        public String getMessage() {
38                StringBuilder b = new StringBuilder();
39                if (message != null) {
40                        b.append(message);
41                }
42                if (arguments != null) {
43                        if (message != null) {
44                                b.append(" ");
45                        }
46                        Delimeted d = new Delimeted(", ", "");
47                        d.append(arguments.iterator());
48
49                        b.append("(").append(d.build()).append(")");
50                }
51                return b.toString();
52        }
53
54}
Note: See TracBrowser for help on using the repository browser.