#841 - Added builder API to HalLinkRelation.
This allows more convenient setup of multiple HalLinkRelation instances for the same curie. Additional unit tests.
This commit is contained in:
@@ -105,6 +105,16 @@ public class HalLinkRelation implements LinkRelation, MessageSourceResolvable {
|
||||
return new HalLinkRelation(null, rel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link HalLinkRelationBuilder} for the given curie.
|
||||
*
|
||||
* @param curie must not be {@literal null} or empty.
|
||||
* @return will never be {@literal null}.
|
||||
*/
|
||||
public static HalLinkRelationBuilder curieBuilder(String curie) {
|
||||
return relation -> new HalLinkRelation(curie, relation);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link HalLinkRelation} curied to the given value.
|
||||
*
|
||||
@@ -162,6 +172,22 @@ public class HalLinkRelation implements LinkRelation, MessageSourceResolvable {
|
||||
.toArray(String[]::new);
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple builder interface to easily create multiple {@link HalLinkRelation}s for a single curie.
|
||||
*
|
||||
* @author Oliver Drotbohm
|
||||
*/
|
||||
public interface HalLinkRelationBuilder {
|
||||
|
||||
/**
|
||||
* Creates a new {@link HalLinkRelation} based on the current curie settings.
|
||||
*
|
||||
* @param relation must not be {@literal null} or empty.
|
||||
* @return will never be {@literal null}.
|
||||
*/
|
||||
HalLinkRelation relation(String relation);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
|
||||
Reference in New Issue
Block a user