source: java/main/src/main/java/com/framsticks/util/lang/Strings.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.lang;
2
3/**
4 * @author Piotr Sniegowski
5 */
6public abstract class Strings {
7
8        public static String valueOf(Object o) {
9                if (o == null) {
10                        return null;
11                }
12                return o.toString();
13        }
14
15        public static boolean notEmpty(String str) {
16                return str != null && !str.equals("");
17        }
18
19        public static String toStringNullProof(Object object) {
20                if (object == null) {
21                        return "";
22                }
23                return object.toString();
24        }
25
26        public static String collapse(String s) {
27                if (s == null) {
28                        return null;
29                }
30                s = s.trim();
31                return (s.equals("")) ? null : s;
32        }
33
34        public static Pair<String, String> splitIntoPair(String string, char separator, String second) {
35                int pos = string.indexOf(separator);
36                if (pos == -1) {
37                        return new Pair<String, String>(string.substring(0,
38                                        string.length() - 1), second);
39                } else {
40                        return new Pair<String, String>(string.substring(0, pos),
41                                        string.substring(pos + 1));
42                }
43        }
44
45        public static String capitalize(String input) {
46                return input.substring(0, 1).toUpperCase() + input.substring(1);
47        }
48
49        public static String uncapitalize(String input) {
50                return input.substring(0, 1).toLowerCase() + input.substring(1);
51        }
52}
Note: See TracBrowser for help on using the repository browser.