From 104989205bb2b366e20cd09fe58dd2046840d61f Mon Sep 17 00:00:00 2001 From: Dimitry Polivaev Date: Wed, 2 Aug 2017 16:42:41 +0200 Subject: [PATCH 1/2] Add default case to supress warning --- .../common/rest/schemagen/PropertySubTypeMapper.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/mercateo/common/rest/schemagen/PropertySubTypeMapper.java b/src/main/java/com/mercateo/common/rest/schemagen/PropertySubTypeMapper.java index 95d3f14..e77771a 100644 --- a/src/main/java/com/mercateo/common/rest/schemagen/PropertySubTypeMapper.java +++ b/src/main/java/com/mercateo/common/rest/schemagen/PropertySubTypeMapper.java @@ -1,11 +1,11 @@ package com.mercateo.common.rest.schemagen; -import com.mercateo.common.rest.schemagen.generictype.GenericType; - import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; import java.util.Map; +import com.mercateo.common.rest.schemagen.generictype.GenericType; + public final class PropertySubTypeMapper { private PropertySubTypeMapper() { @@ -23,6 +23,8 @@ public static PropertySubType of(GenericType type, PropertyType propertyType) } } break; + default: + } return PropertySubType.NONE; } From cb807e7f3e86841ea7f6aec14dad4ffb61ca9e78 Mon Sep 17 00:00:00 2001 From: Dimitry Polivaev Date: Wed, 2 Aug 2017 16:58:11 +0200 Subject: [PATCH 2/2] interface RelationEnum extends RelationContainer with default getRelation() --- .../schemagen/link/relation/RelationEnum.java | 8 ++++++++ .../link/relation/RelationEnumTest.java | 16 ++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 src/main/java/com/mercateo/common/rest/schemagen/link/relation/RelationEnum.java create mode 100644 src/test/java/com/mercateo/common/rest/schemagen/link/relation/RelationEnumTest.java diff --git a/src/main/java/com/mercateo/common/rest/schemagen/link/relation/RelationEnum.java b/src/main/java/com/mercateo/common/rest/schemagen/link/relation/RelationEnum.java new file mode 100644 index 0000000..785f5ed --- /dev/null +++ b/src/main/java/com/mercateo/common/rest/schemagen/link/relation/RelationEnum.java @@ -0,0 +1,8 @@ +package com.mercateo.common.rest.schemagen.link.relation; + +public interface RelationEnum & RelationEnum> extends RelationContainer { + @Override + default public Relation getRelation() { + return Relation.of(((Enum)this).name().toLowerCase().replace('_', '-')); + } +} diff --git a/src/test/java/com/mercateo/common/rest/schemagen/link/relation/RelationEnumTest.java b/src/test/java/com/mercateo/common/rest/schemagen/link/relation/RelationEnumTest.java new file mode 100644 index 0000000..7eacad2 --- /dev/null +++ b/src/test/java/com/mercateo/common/rest/schemagen/link/relation/RelationEnumTest.java @@ -0,0 +1,16 @@ +package com.mercateo.common.rest.schemagen.link.relation; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.Test; + +public class RelationEnumTest{ + enum TestRelation implements RelationEnum{ + TEST_RELATION + } + + @Test + public void createsDefaultRelationContainer() throws Exception { + assertThat(TestRelation.TEST_RELATION.getRelation().getName()).isEqualTo("test-relation"); + } +}