Skip to content

Commit

Permalink
Merge pull request #44 from dpolivaev/master
Browse files Browse the repository at this point in the history
interface RelationEnum extends RelationContainer with default  getRelation()
  • Loading branch information
wuan committed Aug 3, 2017
2 parents e6e0618 + cb807e7 commit 941d239
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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() {
Expand All @@ -23,6 +23,8 @@ public static PropertySubType of(GenericType<?> type, PropertyType propertyType)
}
}
break;
default:

}
return PropertySubType.NONE;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.mercateo.common.rest.schemagen.link.relation;

public interface RelationEnum<E extends Enum<E> & RelationEnum<E>> extends RelationContainer {
@Override
default public Relation getRelation() {
return Relation.of(((Enum<?>)this).name().toLowerCase().replace('_', '-'));
}
}
Original file line number Diff line number Diff line change
@@ -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<TestRelation>{
TEST_RELATION
}

@Test
public void createsDefaultRelationContainer() throws Exception {
assertThat(TestRelation.TEST_RELATION.getRelation().getName()).isEqualTo("test-relation");
}
}

0 comments on commit 941d239

Please sign in to comment.