Skip to content

Commit

Permalink
interface RelationEnum extends RelationContainer with default
Browse files Browse the repository at this point in the history
getRelation()
  • Loading branch information
Dimitry Polivaev committed Aug 2, 2017
1 parent 1049892 commit cb807e7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
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 cb807e7

Please sign in to comment.