]> git.argeo.org Git - gpl/argeo-suite.git/blob - core/org.argeo.entity.api/src/org/argeo/entity/JcrName.java
Rename Eclipse project.
[gpl/argeo-suite.git] / core / org.argeo.entity.api / src / org / argeo / entity / JcrName.java
1 package org.argeo.entity;
2
3 import java.util.function.Supplier;
4
5 /** Can be applied to {@link Enum}s in order to generate prefixed names. */
6 @FunctionalInterface
7 public interface JcrName extends Supplier<String> {
8 String name();
9
10 default String getPrefix() {
11 return null;
12 }
13
14 default String getNamespace() {
15 return null;
16 }
17
18 @Override
19 default String get() {
20 String prefix = getPrefix();
21 return prefix != null ? prefix + ":" + name() : name();
22 }
23
24 default String withNamespace() {
25 String namespace = getNamespace();
26 if (namespace == null)
27 throw new UnsupportedOperationException("No namespace is specified for " + getClass());
28 return "{" + namespace + "}" + name();
29 }
30 }