Skip to content

Commit d4622bd

Browse files
committed
removed DslBinCustom annotation, its attributes moved to @bin, renamed @bin extra attribute
1 parent 7064d21 commit d4622bd

File tree

10 files changed

+189
-278
lines changed

10 files changed

+189
-278
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ For instance I have been very actively using the framework in [the ZX-Poly emula
1616

1717
# Change log
1818
- **2.0.0-SNAPSHOT**
19+
- __removed DslBinCustom annotation, use @Bin annotation instead__
20+
- __renamed attributes of @Bin annotation to their correct form__
1921
- __reworked object mapping system, removed hacks to instantiate classes, now only mapping to objects allowed, support of private fields mapping is removed__
2022
- __minimal JDK version now 1.8+__
2123
- __minimal Android API now 3.0+__
22-
- __renamed attributes of @Bin annotation, removed `out` prefix__
2324
- added support of getters and setters into mapping
2425
- added `Object newInstance(Class)` method support of mapped classes to generate instances for local classes
2526
- added generating of `makeFIELD()` method for structure types in Java class converter

changelog.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
2.0.0-SNAPSHOT
2+
- __removed DslBinCustom annotation, use @Bin annotation instead__
3+
- __renamed attributes of @Bin annotation to their correct form__
24
- __reworked object mapping system, removed hacks to instantiate classes, now only mapping to objects allowed, support of private fields mapping is removed__
35
- __minimal JDK version now 1.8+__
46
- __minimal Android API now 3.0+__
5-
- __renamed attributes of @Bin annotation, removed `out` prefix__
67
- added support of getters and setters into mapping
78
- added `Object newInstance(Class)` method support of mapped classes to generate instances for local classes
89
- added generating of `makeFIELD()` method for structure types in Java class converter

jbbp/src/main/java/com/igormaznitsa/jbbp/io/AbstractMappedClassFieldObserver.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import com.igormaznitsa.jbbp.model.JBBPFieldLong;
2727
import com.igormaznitsa.jbbp.model.JBBPFieldShort;
2828
import com.igormaznitsa.jbbp.model.JBBPFieldString;
29-
import com.igormaznitsa.jbbp.utils.DslBinCustom;
3029
import com.igormaznitsa.jbbp.utils.JBBPUtils;
3130
import java.lang.reflect.Array;
3231
import java.lang.reflect.Field;
@@ -41,7 +40,7 @@ public abstract class AbstractMappedClassFieldObserver {
4140
/**
4241
* Inside auxiliary method to read object field value.
4342
*
44-
* @param obj an object which field is read
43+
* @param obj an object which field is read
4544
* @param record field record, must not be null
4645
* @return a value from the field of the object
4746
* @throws JBBPException if the field can't be read
@@ -72,30 +71,28 @@ private static void assertFieldArray(final Field field) {
7271
}
7372

7473
/**
75-
* Process an object.
74+
* Process an object. It works only with classes and fields marked by Bin annotations. <b>It doesn't process classes and fields marked by DslBinCustom annotations.</b>
7675
*
7776
* @param obj an object which is an instance of a mapped class, must not be null
7877
* @param field a field where the object has been found, it can be null for first call
7978
* @param customFieldProcessor a processor for custom fields, it can be null
79+
* @see Bin
8080
*/
8181
protected void processObject(final Object obj, Field field, final Object customFieldProcessor) {
8282
JBBPUtils.assertNotNull(obj, "Object must not be null");
8383

8484
final List<MappedFieldRecord> orderedFields = JBBPMapper.findAffectedFields(obj);
8585

86-
//TODO check DslBinCustom
8786
final Bin clazzAnno = obj.getClass().getAnnotation(Bin.class);
88-
final DslBinCustom clazzCustomAnno = obj.getClass().getAnnotation(DslBinCustom.class);
8987
final Bin fieldAnno = field == null ? null : field.getAnnotation(Bin.class);
90-
final DslBinCustom fieldCustomAnno = field == null ? null : field.getAnnotation(DslBinCustom.class);
9188

9289
this.onStructStart(obj, field, clazzAnno == null ? fieldAnno : clazzAnno);
9390

9491
for (final MappedFieldRecord rec : orderedFields) {
9592
Bin binAnno = rec.binAnnotation;
9693

9794
if (binAnno.custom() && customFieldProcessor == null) {
98-
throw new JBBPIllegalArgumentException("The Class '" + obj.getClass().getName() + "' contains the field '" + rec.mappingField.getName() + "\' which is a custom one, you must provide a JBBPCustomFieldWriter instance to save the field.");
95+
throw new JBBPIllegalArgumentException("Class '" + obj.getClass().getName() + "' contains field '" + rec.mappingField.getName() + "\' which is custom one, you must provide JBBPCustomFieldWriter instance to save it.");
9996
}
10097

10198
processObjectField(obj, rec, binAnno, customFieldProcessor);

jbbp/src/main/java/com/igormaznitsa/jbbp/mapper/Bin.java

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,22 @@
5757
*/
5858
String path() default "";
5959

60+
/**
61+
* Name of the custom type.
62+
*
63+
* @return type of the field, if empty then undefined
64+
* @since 2.0.0
65+
*/
66+
String customType() default "";
67+
68+
/**
69+
* Expression to represent array size of the field.
70+
*
71+
* @return array size of the field, if empty then not defined
72+
* @since 2.0.0
73+
*/
74+
String arraySizeExpression() default "";
75+
6076
/**
6177
* Type of mapped parsed structure element.
6278
*
@@ -86,12 +102,11 @@
86102
boolean custom() default false;
87103

88104
/**
89-
* The Field is used by custom field processor and as expression to calculate array length.
90-
*
91-
* @return the extra field as String
92-
* @see JBBPMapperCustomFieldProcessor
105+
* Expression as extra part of type. It means take part in <b>type[:extra]</b>
106+
* @return extra value, if empty then undefined
107+
* @since 2.0.0
93108
*/
94-
String extra() default "";
109+
String typeExtraPartExpression() default "";
95110

96111
/**
97112
* The Value defines how many bytes are actual ones in the field, works for numeric field and arrays and allows make mapping to bit fields.

jbbp/src/main/java/com/igormaznitsa/jbbp/utils/DslBinCustom.java

Lines changed: 0 additions & 61 deletions
This file was deleted.

0 commit comments

Comments
 (0)