import static java.util.Objects.requireNonNull;
+import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import java.util.Arrays;
-import java.util.Map;
+import java.util.Set;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.yangtools.yang.common.QName;
public static final int MIN_DEPTH = 1;
public static final int MAX_DEPTH = 65535;
- public static final String READ_TYPE_TX = "READ";
public static final String WITH_DEFAULTS = "with-defaults";
- public static final String REPORT_ALL_DEFAULT_VALUE = "report-all";
- public static final String REPORT_ALL_TAGGED_DEFAULT_VALUE = "report-all-tagged";
+
+ /**
+ * With-default values, as per
+ * <a href="https://tools.ietf.org/html/rfc8040#section-4.8.9">RFC8040 section 4.8.9</a>.
+ */
+ enum WithDefaults {
+ /**
+ * All data nodes are reported.
+ */
+ REPORT_ALL("report-all"),
+ /**
+ * Data nodes set to the YANG default are not reported.
+ */
+ TRIM("trim"),
+ /**
+ * Data nodes set to the YANG default by the client are reported.
+ */
+ EXPLICIT("explicit"),
+ /**
+ * All data nodes are reported, and defaults are tagged.
+ */
+ REPORT_ALL_TAGGED("report-all-tagged");
+
+ private static final ImmutableMap<String, WithDefaults> VALUES =
+ Maps.uniqueIndex(Arrays.asList(values()), WithDefaults::value);
+
+ private @NonNull String value;
+
+ WithDefaults(final @NonNull String value) {
+ this.value = value;
+ }
+
+ public @NonNull String value() {
+ return value;
+ }
+
+ static @Nullable WithDefaults forValue(final String value) {
+ return VALUES.get(requireNonNull(value));
+ }
+
+ static @Nullable Set<String> possibleValues() {
+ return VALUES.keySet();
+ }
+ }
private ReadData() {
throw new UnsupportedOperationException("Util class.");
*/
AFTER("after");
- private static final Map<String, Insert> VALUES = Maps.uniqueIndex(Arrays.asList(values()), Insert::value);
+ private static final ImmutableMap<String, Insert> VALUES =
+ Maps.uniqueIndex(Arrays.asList(values()), Insert::value);
private @NonNull String value;
// Hidden on purpose
}
}
-
- /**
- * Constants for data to put.
- *
- */
- public static final class PutData {
- public static final String PUT_TX_TYPE = "PUT";
-
- private PutData() {
- throw new UnsupportedOperationException("Util class.");
- }
- }
-
- /**
- * Constants for data to post.
- *
- */
- public static final class PostData {
- public static final String POST_TX_TYPE = "POST";
-
- private PostData() {
- throw new UnsupportedOperationException("Util class.");
- }
- }
-
- /**
- * Constants for data to delete.
- *
- */
- public static final class DeleteData {
- public static final String DELETE_TX_TYPE = "DELETE";
-
- private DeleteData() {
- throw new UnsupportedOperationException("Util class.");
- }
- }
-
- /**
- * Constants for data to yang patch.
- *
- */
- public static final class PatchData {
- public static final String PATCH_TX_TYPE = "Patch";
-
- private PatchData() {
- throw new UnsupportedOperationException("Util class.");
- }
- }
}