@Nullable private static ChangeType convertChangeType(com.linecorp.centraldogma.common.ChangeType type) { if (type == null) { return null; } return ChangeType.valueOf(type.name()); } }
DefaultChange(String path, ChangeType type, @Nullable T content) { this.type = requireNonNull(type, "type"); if (type.contentType() == JsonNode.class) { validateJsonFilePath(path, "path"); } else { validateFilePath(path, "path"); } this.path = path; this.content = content; }
@Override public int hashCode() { return type.hashCode() * 31 + path.hashCode(); }
/** * Returns a {@link ChangeType} from the specified {@code value} case-insensitively. */ public static ChangeType parse(String value) { requireNonNull(value, "value"); checkArgument(!value.isEmpty(), "the value for ChangeType should not be empty."); return valueOf(Ascii.toUpperCase(value)); } }
private static Change<?> readChange(JsonNode node) { checkArgument(node.get("path") != null && node.get("type") != null, "a change should have a path and a type"); final ChangeType changeType = ChangeType.parse(node.get("type").textValue()); if (changeType != ChangeType.REMOVE) { checkArgument(node.get("content") != null, "a change should have a content.");
/** * Returns a {@link ChangeType} from the specified {@code value} case-insensitively. */ public static ChangeType parse(String value) { requireNonNull(value, "value"); checkArgument(!value.isEmpty(), "the value for ChangeType should not be empty."); return valueOf(Ascii.toUpperCase(value)); } }
private static Change<?> readChange(JsonNode node) { checkArgument(node.get("path") != null && node.get("type") != null, "a change should have a path and a type"); final ChangeType changeType = ChangeType.parse(node.get("type").textValue()); if (changeType != ChangeType.REMOVE) { checkArgument(node.get("content") != null, "a change should have a content.");
@Nullable static ChangeType convert(@Nullable com.linecorp.centraldogma.common.ChangeType type) { if (type == null) { return null; } return ChangeType.valueOf(type.name()); } ////////////////
DefaultChange(String path, ChangeType type, @Nullable T content) { this.type = requireNonNull(type, "type"); if (type.contentType() == JsonNode.class) { validateJsonFilePath(path, "path"); } else { validateFilePath(path, "path"); } this.path = path; this.content = content; }
/** * Returns a {@link ChangeType} from the specified {@code value} case-insensitively. */ public static ChangeType parse(String value) { requireNonNull(value, "value"); checkArgument(!value.isEmpty(), "the value for ChangeType should not be empty."); return valueOf(Ascii.toUpperCase(value)); } }
@Override public int hashCode() { return type.hashCode() * 31 + path.hashCode(); }
private static Change<?> readChange(JsonNode node) { checkArgument(node.get("path") != null && node.get("type") != null, "a change should have a path and a type"); final ChangeType changeType = ChangeType.parse(node.get("type").textValue()); if (changeType != ChangeType.REMOVE) { checkArgument(node.get("content") != null, "a change should have a content.");
@Nullable static ChangeType convert(@Nullable com.linecorp.centraldogma.common.ChangeType type) { if (type == null) { return null; } return ChangeType.valueOf(type.name()); } ////////////////
DefaultChange(String path, ChangeType type, @Nullable T content) { this.type = requireNonNull(type, "type"); if (type.contentType() == JsonNode.class) { validateJsonFilePath(path, "path"); } else { validateFilePath(path, "path"); } this.path = path; this.content = content; }
@Override public int hashCode() { return type.hashCode() * 31 + path.hashCode(); }
@Nullable private static ChangeType convertChangeType(com.linecorp.centraldogma.common.ChangeType type) { if (type == null) { return null; } return ChangeType.valueOf(type.name()); } }
@JsonProperty("content") @Nullable JsonNode content) { requireNonNull(type, "type"); final Class<?> contentType = type.contentType(); if (contentType == Void.class) { if (content != null && !content.isNull()) { return rejectIncompatibleContent(content, Void.class); } else if (type.contentType() == String.class) { if (content == null || !content.isTextual()) { return rejectIncompatibleContent(content, String.class);
@Nullable static ChangeType convert(@Nullable com.linecorp.centraldogma.common.ChangeType type) { if (type == null) { return null; } return ChangeType.valueOf(type.name()); } ////////////////
@JsonProperty("content") @Nullable JsonNode content) { requireNonNull(type, "type"); final Class<?> contentType = type.contentType(); if (contentType == Void.class) { if (content != null && !content.isNull()) { return rejectIncompatibleContent(content, Void.class); } else if (type.contentType() == String.class) { if (content == null || !content.isTextual()) { return rejectIncompatibleContent(content, String.class);
static ChangeDto convert(Change<?> change) { final ChangeDto dto = new ChangeDto(); dto.setPath(change.path()); dto.setType(change.type().name()); dto.setContent(change.contentAsText()); return dto; }