Latest bnd code
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1350613 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/bundleplugin/src/main/java/aQute/lib/data/AllowNull.java b/bundleplugin/src/main/java/aQute/lib/data/AllowNull.java
index 2bbf253..0b25300 100644
--- a/bundleplugin/src/main/java/aQute/lib/data/AllowNull.java
+++ b/bundleplugin/src/main/java/aQute/lib/data/AllowNull.java
@@ -3,7 +3,9 @@
import java.lang.annotation.*;
@Retention(RetentionPolicy.RUNTIME)
-@Target(value={ElementType.FIELD})
+@Target(value = {
+ ElementType.FIELD
+})
public @interface AllowNull {
String reason() default "";
}
diff --git a/bundleplugin/src/main/java/aQute/lib/data/Data.java b/bundleplugin/src/main/java/aQute/lib/data/Data.java
index d790d2e..f44d1a7 100644
--- a/bundleplugin/src/main/java/aQute/lib/data/Data.java
+++ b/bundleplugin/src/main/java/aQute/lib/data/Data.java
@@ -20,7 +20,6 @@
if (allowNull == null)
formatter.format("Value for %s must not be null\n", f.getName());
} else {
-
if (patternValidator != null) {
Pattern p = Pattern.compile(patternValidator.value());
@@ -28,8 +27,8 @@
if (!m.matches()) {
String reason = patternValidator.reason();
if (reason.length() == 0)
- formatter.format("Value for %s=%s does not match pattern %s\n",
- f.getName(), value, patternValidator.value());
+ formatter.format("Value for %s=%s does not match pattern %s\n", f.getName(), value,
+ patternValidator.value());
else
formatter.format("Value for %s=%s %s\n", f.getName(), value, reason);
}
@@ -39,29 +38,31 @@
if (o instanceof String) {
try {
o = Double.parseDouble((String) o);
- } catch (Exception e) {
+ }
+ catch (Exception e) {
formatter.format("Value for %s=%s %s\n", f.getName(), value, "Not a number");
}
}
-
+
try {
Number n = (Number) o;
long number = n.longValue();
if (number >= numericValidator.min() && number < numericValidator.max()) {
- formatter.format("Value for %s=%s not in valid range (%s,%s]\n",
- f.getName(), value, numericValidator.min(), numericValidator.max());
+ formatter.format("Value for %s=%s not in valid range (%s,%s]\n", f.getName(), value,
+ numericValidator.min(), numericValidator.max());
}
- } catch (ClassCastException e) {
+ }
+ catch (ClassCastException e) {
formatter.format("Value for %s=%s [%s,%s) is not a number\n", f.getName(), value,
numericValidator.min(), numericValidator.max());
}
}
}
}
- if ( sb.length() == 0)
+ if (sb.length() == 0)
return null;
-
- if ( sb.length() > 0)
+
+ if (sb.length() > 0)
sb.delete(sb.length() - 1, sb.length());
return sb.toString();
}
@@ -69,8 +70,8 @@
public static void details(Object data, Appendable out) throws Exception {
Field fields[] = data.getClass().getFields();
Formatter formatter = new Formatter(out);
-
- for ( Field f : fields ) {
+
+ for (Field f : fields) {
String name = f.getName();
name = Character.toUpperCase(name.charAt(0)) + name.substring(1);
formatter.format("%-40s %s\n", name, f.get(data));
diff --git a/bundleplugin/src/main/java/aQute/lib/data/Numeric.java b/bundleplugin/src/main/java/aQute/lib/data/Numeric.java
index 19d60cf..eb1534e 100644
--- a/bundleplugin/src/main/java/aQute/lib/data/Numeric.java
+++ b/bundleplugin/src/main/java/aQute/lib/data/Numeric.java
@@ -3,9 +3,13 @@
import java.lang.annotation.*;
@Retention(RetentionPolicy.RUNTIME)
-@Target(value={ElementType.FIELD})
+@Target(value = {
+ ElementType.FIELD
+})
public @interface Numeric {
long min() default Long.MIN_VALUE;
+
long max() default Long.MAX_VALUE;
+
String reason() default "";
}
diff --git a/bundleplugin/src/main/java/aQute/lib/data/Validator.java b/bundleplugin/src/main/java/aQute/lib/data/Validator.java
index e8a8d4f..48324e8 100644
--- a/bundleplugin/src/main/java/aQute/lib/data/Validator.java
+++ b/bundleplugin/src/main/java/aQute/lib/data/Validator.java
@@ -3,8 +3,11 @@
import java.lang.annotation.*;
@Retention(RetentionPolicy.RUNTIME)
-@Target(value={ElementType.FIELD})
+@Target(value = {
+ ElementType.FIELD
+})
public @interface Validator {
String value();
+
String reason() default "";
}