-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from dpolivaev/master
interface RelationEnum extends RelationContainer with default getRelation()
- Loading branch information
Showing
3 changed files
with
28 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
src/main/java/com/mercateo/common/rest/schemagen/link/relation/RelationEnum.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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('_', '-')); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/test/java/com/mercateo/common/rest/schemagen/link/relation/RelationEnumTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
} |