Skip to content

Commit ce8b284

Browse files
committed
simplify EntryBuilder method signatures
1 parent e837644 commit ce8b284

File tree

2 files changed

+17
-18
lines changed

2 files changed

+17
-18
lines changed

lightblue-ldap-crud/src/main/java/com/redhat/lightblue/crud/ldap/EntryBuilder.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
import com.redhat.lightblue.metadata.types.DateType;
3636
import com.redhat.lightblue.util.JsonDoc;
3737
import com.redhat.lightblue.util.JsonNodeCursor;
38-
import com.redhat.lightblue.util.Path;
3938
import com.unboundid.ldap.sdk.Entry;
4039
import com.unboundid.util.StaticUtils;
4140

@@ -73,8 +72,8 @@ else if(type instanceof BinaryType){
7372
}
7473

7574
@Override
76-
protected void translate(SimpleField field, Path path, JsonNode node, Entry target) {
77-
String attributeName = fieldNameTranslator.translateFieldName(path);
75+
protected void translate(SimpleField field, JsonNode node, Entry target) {
76+
String attributeName = fieldNameTranslator.translateFieldName(field.getFullPath());
7877

7978
if(LdapConstant.ATTRIBUTE_DN.equalsIgnoreCase(attributeName)){
8079
throw new IllegalArgumentException(
@@ -101,10 +100,10 @@ else if(LightblueUtil.isFieldObjectType(attributeName)
101100
}
102101

103102
@Override
104-
protected void translateSimpleArray(ArrayField field, Path path, List<Object> items, Entry target) {
103+
protected void translateSimpleArray(ArrayField field, List<Object> items, Entry target) {
105104
ArrayElement arrayElement = field.getElement();
106105
Type arrayElementType = arrayElement.getType();
107-
String attributeName = fieldNameTranslator.translateFieldName(path);
106+
String attributeName = fieldNameTranslator.translateFieldName(field.getFullPath());
108107

109108
if(arrayElementType instanceof BinaryType){
110109
List<byte[]> bytes = new ArrayList<byte[]>();
@@ -123,7 +122,7 @@ protected void translateSimpleArray(ArrayField field, Path path, List<Object> it
123122
}
124123

125124
@Override
126-
protected void translateObjectArray(ArrayField field, JsonNodeCursor cursor, Path path, Entry target) {
125+
protected void translateObjectArray(ArrayField field, JsonNodeCursor cursor, Entry target) {
127126
throw new UnsupportedOperationException("Object ArrayField type is not currently supported.");
128127
}
129128

lightblue-ldap-crud/src/main/java/com/redhat/lightblue/crud/ldap/TranslatorFromJson.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -103,23 +103,23 @@ protected void translate(JsonNodeCursor cursor, T target){
103103
}
104104

105105
if (fieldNode instanceof SimpleField) {
106-
translate((SimpleField) fieldNode, path, node, target);
106+
translate((SimpleField) fieldNode, node, target);
107107
}
108108
else if (fieldNode instanceof ObjectField) {
109-
translate((ObjectField) fieldNode, cursor, path, target);
109+
translate((ObjectField) fieldNode, cursor, target);
110110
}
111111
else if (fieldNode instanceof ArrayField) {
112-
translate((ArrayField) fieldNode, cursor, path, target);
112+
translate((ArrayField) fieldNode, cursor, target);
113113
}
114114
else if (fieldNode instanceof ReferenceField) {
115-
translate((ReferenceField) fieldNode, path, node, target);
115+
translate((ReferenceField) fieldNode, node, target);
116116
}
117117
else{
118118
throw new UnsupportedOperationException("Field type is not supported: " + fieldNode.getClass().getName());
119119
}
120120
}
121121

122-
private void translate(ArrayField field, JsonNodeCursor cursor, Path path, T target){
122+
private void translate(ArrayField field, JsonNodeCursor cursor, T target){
123123
if(!cursor.firstChild()){
124124
//TODO: throw exception?
125125
return;
@@ -132,10 +132,10 @@ private void translate(ArrayField field, JsonNodeCursor cursor, Path path, T tar
132132
do {
133133
items.add(fromJson(arrayElement.getType(), cursor.getCurrentNode()));
134134
} while (cursor.nextSibling());
135-
translateSimpleArray(field, path, items, target);
135+
translateSimpleArray(field, items, target);
136136
}
137137
else if(arrayElement instanceof ObjectArrayElement){
138-
translateObjectArray(field, cursor, path, target);
138+
translateObjectArray(field, cursor, target);
139139
}
140140
else{
141141
throw new UnsupportedOperationException("ArrayElement type is not supported: " + arrayElement.getClass().getName());
@@ -144,7 +144,7 @@ else if(arrayElement instanceof ObjectArrayElement){
144144
cursor.parent();
145145
}
146146

147-
protected void translate(ObjectField field, JsonNodeCursor cursor, Path path, T target){
147+
protected void translate(ObjectField field, JsonNodeCursor cursor, T target){
148148
if(!cursor.firstChild()){
149149
//TODO: throw exception?
150150
return;
@@ -156,12 +156,12 @@ protected void translate(ObjectField field, JsonNodeCursor cursor, Path path, T
156156
cursor.parent();
157157
}
158158

159-
protected void translate(ReferenceField field, Path path, JsonNode node, T target){
159+
protected void translate(ReferenceField field, JsonNode node, T target){
160160
//Do nothing by default!
161161
}
162162

163-
protected abstract void translate(SimpleField field, Path path, JsonNode node, T target);
164-
protected abstract void translateSimpleArray(ArrayField field, Path path, List<Object> items, T target);
165-
protected abstract void translateObjectArray(ArrayField field, JsonNodeCursor cursor, Path path, T target);
163+
protected abstract void translate(SimpleField field, JsonNode node, T target);
164+
protected abstract void translateSimpleArray(ArrayField field, List<Object> items, T target);
165+
protected abstract void translateObjectArray(ArrayField field, JsonNodeCursor cursor, T target);
166166

167167
}

0 commit comments

Comments
 (0)