summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main/java/org/openecomp/sdc/be/view/MixinModelWriter.java
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-be/src/main/java/org/openecomp/sdc/be/view/MixinModelWriter.java')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/view/MixinModelWriter.java39
1 files changed, 17 insertions, 22 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/view/MixinModelWriter.java b/catalog-be/src/main/java/org/openecomp/sdc/be/view/MixinModelWriter.java
index d7f07baccb..0f8cbf4182 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/view/MixinModelWriter.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/view/MixinModelWriter.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,17 +17,10 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.view;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
-
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.ext.MessageBodyWriter;
-import javax.ws.rs.ext.Provider;
import java.io.IOException;
import java.io.OutputStream;
import java.lang.annotation.Annotation;
@@ -36,9 +29,15 @@ import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import java.util.stream.Stream;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyWriter;
+import javax.ws.rs.ext.Provider;
/**
- * A class that is then responsible for converting a message payload with a dedicated mixin from an instance of a specific Java type into a json representation.
+ * A class that is then responsible for converting a message payload with a dedicated mixin from an instance of a specific Java type into a json
+ * representation.
*/
@Provider
@Produces(MediaType.APPLICATION_JSON)
@@ -55,7 +54,8 @@ public class MixinModelWriter implements MessageBodyWriter<Object> {
}
@Override
- public void writeTo(Object object, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException {
+ public void writeTo(Object object, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType,
+ MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException {
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
List<MixinSourceTarget> mixinSourceTargets = getMixinSourceTarget(annotations);
@@ -64,19 +64,14 @@ public class MixinModelWriter implements MessageBodyWriter<Object> {
}
private List<MixinSourceTarget> getMixinSourceTarget(Annotation[] annotations) {
- return Stream.of(annotations)
- .filter(annotation -> annotation.annotationType().equals(ResponseView.class))
- .map(annotation -> (ResponseView) annotation)
- .flatMap(responseView -> Stream.of(responseView.mixin()))
- .map(mixinClass -> new MixinSourceTarget(mixinClass, mixinClass.getAnnotation(MixinTarget.class).target()))
- .collect(Collectors.toList());
+ return Stream.of(annotations).filter(annotation -> annotation.annotationType().equals(ResponseView.class))
+ .map(annotation -> (ResponseView) annotation).flatMap(responseView -> Stream.of(responseView.mixin()))
+ .map(mixinClass -> new MixinSourceTarget(mixinClass, mixinClass.getAnnotation(MixinTarget.class).target())).collect(Collectors.toList());
}
private boolean hasResponseViewAndMixinTargetAnnotations(Annotation[] annotations) {
- return Stream.of(annotations)
- .filter(annotation -> annotation.annotationType().equals(ResponseView.class))
- .map(annotation -> (ResponseView) annotation)
- .flatMap(responseView -> Stream.of(responseView.mixin()))
- .anyMatch(mixinClass -> Objects.nonNull(mixinClass.getAnnotation(MixinTarget.class)));
+ return Stream.of(annotations).filter(annotation -> annotation.annotationType().equals(ResponseView.class))
+ .map(annotation -> (ResponseView) annotation).flatMap(responseView -> Stream.of(responseView.mixin()))
+ .anyMatch(mixinClass -> Objects.nonNull(mixinClass.getAnnotation(MixinTarget.class)));
}
}