[OLINGO-659] Renamed setter/getter to fit code conventions
This commit is contained in:
parent
547cd0a79e
commit
87f829e5ae
|
@ -30,7 +30,7 @@ public class EntityCollectionSerializerOptions {
|
||||||
private CountOption count;
|
private CountOption count;
|
||||||
private ExpandOption expand;
|
private ExpandOption expand;
|
||||||
private SelectOption select;
|
private SelectOption select;
|
||||||
private boolean onlyReferences;
|
private boolean writeOnlyReferences;
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
/** Gets the {@link ContextURL}. */
|
/** Gets the {@link ContextURL}. */
|
||||||
|
@ -54,8 +54,8 @@ public class EntityCollectionSerializerOptions {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** only writes the references of the entities */
|
/** only writes the references of the entities */
|
||||||
public boolean onlyReferences() {
|
public boolean getWriteOnlyReferences() {
|
||||||
return onlyReferences;
|
return writeOnlyReferences;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Gets the id of the entity collection */
|
/** Gets the id of the entity collection */
|
||||||
|
@ -102,13 +102,13 @@ public class EntityCollectionSerializerOptions {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Sets to serialize only references */
|
/** Sets to serialize only references */
|
||||||
public Builder setWriteOnlyReferences(final boolean ref) {
|
public Builder writeOnlyReferences(final boolean ref) {
|
||||||
options.onlyReferences = ref;
|
options.writeOnlyReferences = ref;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Sets id of the collection */
|
/** Sets id of the collection */
|
||||||
public Builder setId(final String id) {
|
public Builder id(final String id) {
|
||||||
options.id = id;
|
options.id = id;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ public class EntitySerializerOptions {
|
||||||
private ContextURL contextURL;
|
private ContextURL contextURL;
|
||||||
private ExpandOption expand;
|
private ExpandOption expand;
|
||||||
private SelectOption select;
|
private SelectOption select;
|
||||||
private boolean onlyReferences;
|
private boolean writeOnlyReferences;
|
||||||
|
|
||||||
/** Gets the {@link ContextURL}. */
|
/** Gets the {@link ContextURL}. */
|
||||||
public ContextURL getContextURL() {
|
public ContextURL getContextURL() {
|
||||||
|
@ -45,8 +45,8 @@ public class EntitySerializerOptions {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** only writes the references of the entities */
|
/** only writes the references of the entities */
|
||||||
public boolean onlyReferences() {
|
public boolean getWriteOnlyReferences() {
|
||||||
return onlyReferences;
|
return writeOnlyReferences;
|
||||||
}
|
}
|
||||||
|
|
||||||
private EntitySerializerOptions() {}
|
private EntitySerializerOptions() {}
|
||||||
|
@ -84,8 +84,8 @@ public class EntitySerializerOptions {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Sets to serialize only references */
|
/** Sets to serialize only references */
|
||||||
public Builder setWriteOnlyReferences(final boolean ref) {
|
public Builder writeOnlyReferences(final boolean ref) {
|
||||||
options.onlyReferences = ref;
|
options.writeOnlyReferences = ref;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -147,13 +147,13 @@ public abstract class ServiceRequest {
|
||||||
return (T) EntitySerializerOptions.with()
|
return (T) EntitySerializerOptions.with()
|
||||||
.contextURL(isODataMetadataNone(getResponseContentType()) ? null : contextUrl)
|
.contextURL(isODataMetadataNone(getResponseContentType()) ? null : contextUrl)
|
||||||
.expand(uriInfo.getExpandOption()).select(this.uriInfo.getSelectOption())
|
.expand(uriInfo.getExpandOption()).select(this.uriInfo.getSelectOption())
|
||||||
.setWriteOnlyReferences(references).build();
|
.writeOnlyReferences(references).build();
|
||||||
} else if (serilizerOptions.isAssignableFrom(EntityCollectionSerializerOptions.class)) {
|
} else if (serilizerOptions.isAssignableFrom(EntityCollectionSerializerOptions.class)) {
|
||||||
return (T) EntityCollectionSerializerOptions.with()
|
return (T) EntityCollectionSerializerOptions.with()
|
||||||
.contextURL(isODataMetadataNone(getResponseContentType()) ? null : contextUrl)
|
.contextURL(isODataMetadataNone(getResponseContentType()) ? null : contextUrl)
|
||||||
.count(uriInfo.getCountOption()).expand(uriInfo.getExpandOption())
|
.count(uriInfo.getCountOption()).expand(uriInfo.getExpandOption())
|
||||||
.select(uriInfo.getSelectOption()).setWriteOnlyReferences(references)
|
.select(uriInfo.getSelectOption()).writeOnlyReferences(references)
|
||||||
.setId(getODataRequest().getRawBaseUri()+getODataRequest().getRawODataPath()).build();
|
.id(getODataRequest().getRawBaseUri() + getODataRequest().getRawODataPath()).build();
|
||||||
} else if (serilizerOptions.isAssignableFrom(ComplexSerializerOptions.class)) {
|
} else if (serilizerOptions.isAssignableFrom(ComplexSerializerOptions.class)) {
|
||||||
return (T) ComplexSerializerOptions.with().contextURL(contextUrl)
|
return (T) ComplexSerializerOptions.with().contextURL(contextUrl)
|
||||||
.expand(this.uriInfo.getExpandOption()).select(this.uriInfo.getSelectOption()).build();
|
.expand(this.uriInfo.getExpandOption()).select(this.uriInfo.getSelectOption()).build();
|
||||||
|
|
|
@ -157,7 +157,7 @@ public class ODataJsonSerializer extends AbstractODataSerializer {
|
||||||
writeEntitySet(metadata, entityType, entitySet, null, null, false, json);
|
writeEntitySet(metadata, entityType, entitySet, null, null, false, json);
|
||||||
} else {
|
} else {
|
||||||
writeEntitySet(metadata, entityType, entitySet,
|
writeEntitySet(metadata, entityType, entitySet,
|
||||||
options.getExpand(), options.getSelect(), options.onlyReferences(), json);
|
options.getExpand(), options.getSelect(), options.getWriteOnlyReferences(), json);
|
||||||
}
|
}
|
||||||
writeNextLink(entitySet, json);
|
writeNextLink(entitySet, json);
|
||||||
|
|
||||||
|
@ -186,7 +186,7 @@ public class ODataJsonSerializer extends AbstractODataSerializer {
|
||||||
writeEntity(metadata, entityType, entity, contextURL,
|
writeEntity(metadata, entityType, entity, contextURL,
|
||||||
options == null ? null : options.getExpand(),
|
options == null ? null : options.getExpand(),
|
||||||
options == null ? null : options.getSelect(),
|
options == null ? null : options.getSelect(),
|
||||||
options == null ? false : options.onlyReferences(),
|
options == null ? false : options.getWriteOnlyReferences(),
|
||||||
json);
|
json);
|
||||||
|
|
||||||
json.close();
|
json.close();
|
||||||
|
|
|
@ -213,7 +213,7 @@ public class ODataXmlSerializer extends AbstractODataSerializer {
|
||||||
final EntityCollectionSerializerOptions options) throws SerializerException {
|
final EntityCollectionSerializerOptions options) throws SerializerException {
|
||||||
|
|
||||||
final ContextURL contextURL = checkContextURL(options == null ? null : options.getContextURL());
|
final ContextURL contextURL = checkContextURL(options == null ? null : options.getContextURL());
|
||||||
if (options != null && options.onlyReferences()) {
|
if (options != null && options.getWriteOnlyReferences()) {
|
||||||
ReferenceCollectionSerializerOptions rso = ReferenceCollectionSerializerOptions.with()
|
ReferenceCollectionSerializerOptions rso = ReferenceCollectionSerializerOptions.with()
|
||||||
.contextURL(contextURL).build();
|
.contextURL(contextURL).build();
|
||||||
return entityReferenceCollection(entitySet, rso);
|
return entityReferenceCollection(entitySet, rso);
|
||||||
|
@ -282,7 +282,7 @@ public class ODataXmlSerializer extends AbstractODataSerializer {
|
||||||
final Entity entity, final EntitySerializerOptions options) throws SerializerException {
|
final Entity entity, final EntitySerializerOptions options) throws SerializerException {
|
||||||
final ContextURL contextURL = checkContextURL(options == null ? null : options.getContextURL());
|
final ContextURL contextURL = checkContextURL(options == null ? null : options.getContextURL());
|
||||||
|
|
||||||
if (options != null && options.onlyReferences()) {
|
if (options != null && options.getWriteOnlyReferences()) {
|
||||||
return entityReference(entity,
|
return entityReference(entity,
|
||||||
ReferenceSerializerOptions.with().contextURL(contextURL).build());
|
ReferenceSerializerOptions.with().contextURL(contextURL).build());
|
||||||
}
|
}
|
||||||
|
|
|
@ -536,7 +536,7 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
|
||||||
getContextUrl(request.getRawODataPath(), edmEntitySet, edmEntityType, false, expand, select))
|
getContextUrl(request.getRawODataPath(), edmEntitySet, edmEntityType, false, expand, select))
|
||||||
.count(countOption)
|
.count(countOption)
|
||||||
.expand(expand).select(select)
|
.expand(expand).select(select)
|
||||||
.setId(id)
|
.id(id)
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -270,7 +270,7 @@ public class ODataXmlSerializerTest {
|
||||||
EntityCollectionSerializerOptions.with()
|
EntityCollectionSerializerOptions.with()
|
||||||
.contextURL(ContextURL.with().serviceRoot(new URI("http://host:port"))
|
.contextURL(ContextURL.with().serviceRoot(new URI("http://host:port"))
|
||||||
.entitySet(edmEntitySet).build())
|
.entitySet(edmEntitySet).build())
|
||||||
.setId("http://host/svc/ESCompAllPrim")
|
.id("http://host/svc/ESCompAllPrim")
|
||||||
.count(countOption)
|
.count(countOption)
|
||||||
.build()).getContent();
|
.build()).getContent();
|
||||||
final String resultString = IOUtils.toString(result);
|
final String resultString = IOUtils.toString(result);
|
||||||
|
@ -635,7 +635,7 @@ public class ODataXmlSerializerTest {
|
||||||
edmEntitySet.getEntityType(), entitySet,
|
edmEntitySet.getEntityType(), entitySet,
|
||||||
EntityCollectionSerializerOptions.with()
|
EntityCollectionSerializerOptions.with()
|
||||||
.contextURL(ContextURL.with().entitySet(edmEntitySet).build())
|
.contextURL(ContextURL.with().entitySet(edmEntitySet).build())
|
||||||
.setId("http://host/svc/ESMedia")
|
.id("http://host/svc/ESMedia")
|
||||||
.build()).getContent();
|
.build()).getContent();
|
||||||
final String resultString = IOUtils.toString(content);
|
final String resultString = IOUtils.toString(content);
|
||||||
|
|
||||||
|
@ -732,7 +732,7 @@ public class ODataXmlSerializerTest {
|
||||||
EntityCollectionSerializerOptions.with()
|
EntityCollectionSerializerOptions.with()
|
||||||
.contextURL(ContextURL.with().serviceRoot(URI.create("http://host/svc"))
|
.contextURL(ContextURL.with().serviceRoot(URI.create("http://host/svc"))
|
||||||
.entitySet(edmEntitySet).build())
|
.entitySet(edmEntitySet).build())
|
||||||
.setId("http://host/svc/ESAllNullable")
|
.id("http://host/svc/ESAllNullable")
|
||||||
.build()).getContent();
|
.build()).getContent();
|
||||||
final String resultString = IOUtils.toString(content);
|
final String resultString = IOUtils.toString(content);
|
||||||
String expected = "<?xml version='1.0' encoding='UTF-8'?>\n" +
|
String expected = "<?xml version='1.0' encoding='UTF-8'?>\n" +
|
||||||
|
@ -928,7 +928,7 @@ public class ODataXmlSerializerTest {
|
||||||
.contextURL(ContextURL.with().entitySet(edmEntitySet)
|
.contextURL(ContextURL.with().entitySet(edmEntitySet)
|
||||||
.selectList(helper.buildContextURLSelectList(entityType, null, select))
|
.selectList(helper.buildContextURLSelectList(entityType, null, select))
|
||||||
.build())
|
.build())
|
||||||
.setId("http://host/svc/ESCompComp")
|
.id("http://host/svc/ESCompComp")
|
||||||
.select(select)
|
.select(select)
|
||||||
.build()).getContent();
|
.build()).getContent();
|
||||||
final String resultString = IOUtils.toString(result);
|
final String resultString = IOUtils.toString(result);
|
||||||
|
@ -1002,7 +1002,7 @@ public class ODataXmlSerializerTest {
|
||||||
.contextURL(ContextURL.with().entitySet(edmEntitySet)
|
.contextURL(ContextURL.with().entitySet(edmEntitySet)
|
||||||
.selectList(helper.buildContextURLSelectList(entityType, null, select))
|
.selectList(helper.buildContextURLSelectList(entityType, null, select))
|
||||||
.build())
|
.build())
|
||||||
.setId("http://host/svc/ESCompComp")
|
.id("http://host/svc/ESCompComp")
|
||||||
.select(select)
|
.select(select)
|
||||||
.build()).getContent();
|
.build()).getContent();
|
||||||
final String resultString = IOUtils.toString(inputStream);
|
final String resultString = IOUtils.toString(inputStream);
|
||||||
|
|
|
@ -82,7 +82,7 @@ public class DemoEntityCollectionProcessor implements EntityCollectionProcessor
|
||||||
|
|
||||||
final String id = request.getRawBaseUri() + "/" + edmEntitySet.getName();
|
final String id = request.getRawBaseUri() + "/" + edmEntitySet.getName();
|
||||||
EntityCollectionSerializerOptions opts =
|
EntityCollectionSerializerOptions opts =
|
||||||
EntityCollectionSerializerOptions.with().setId(id).contextURL(contextUrl).build();
|
EntityCollectionSerializerOptions.with().id(id).contextURL(contextUrl).build();
|
||||||
SerializerResult serializedContent = serializer.entityCollection(serviceMetadata, edmEntityType, entitySet, opts);
|
SerializerResult serializedContent = serializer.entityCollection(serviceMetadata, edmEntityType, entitySet, opts);
|
||||||
|
|
||||||
// Finally: configure the response object: set the body, headers and status code
|
// Finally: configure the response object: set the body, headers and status code
|
||||||
|
|
|
@ -136,7 +136,7 @@ public class DemoEntityCollectionProcessor implements EntityCollectionProcessor
|
||||||
|
|
||||||
final String id = request.getRawBaseUri() + "/" + edmEntitySet.getName();
|
final String id = request.getRawBaseUri() + "/" + edmEntitySet.getName();
|
||||||
EntityCollectionSerializerOptions opts =
|
EntityCollectionSerializerOptions opts =
|
||||||
EntityCollectionSerializerOptions.with().setId(id).contextURL(contextUrl).build();
|
EntityCollectionSerializerOptions.with().id(id).contextURL(contextUrl).build();
|
||||||
SerializerResult serializerResult = serializer.entityCollection(serviceMetadata, edmEntityType,
|
SerializerResult serializerResult = serializer.entityCollection(serviceMetadata, edmEntityType,
|
||||||
entityCollection, opts);
|
entityCollection, opts);
|
||||||
InputStream serializedContent = serializerResult.getContent();
|
InputStream serializedContent = serializerResult.getContent();
|
||||||
|
|
|
@ -124,7 +124,7 @@ public class DemoEntityCollectionProcessor implements EntityCollectionProcessor
|
||||||
|
|
||||||
final String id = request.getRawBaseUri() + "/" + edmEntitySet.getName();
|
final String id = request.getRawBaseUri() + "/" + edmEntitySet.getName();
|
||||||
EntityCollectionSerializerOptions opts = EntityCollectionSerializerOptions.with()
|
EntityCollectionSerializerOptions opts = EntityCollectionSerializerOptions.with()
|
||||||
.contextURL(contextUrl).setId(id).build();
|
.contextURL(contextUrl).id(id).build();
|
||||||
SerializerResult serializerResult = serializer.entityCollection(serviceMetadata, edmEntityType, entityCollection,
|
SerializerResult serializerResult = serializer.entityCollection(serviceMetadata, edmEntityType, entityCollection,
|
||||||
opts);
|
opts);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue