Java tutorial
/******************************************************************************* * Copyright 2013 Matias Surdi * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under * the License. ******************************************************************************/ package io.github.msurdi.redeye.api; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Data; import lombok.experimental.Builder; import java.util.UUID; /** * Representation of a Query */ @Data public class Query implements Indexable { private final String id; private final String query; private final String name; private final String description; @Builder @JsonCreator public Query(@JsonProperty("id") String id, @JsonProperty("query") String query, @JsonProperty("name") String name, @JsonProperty("description") String description) { this.id = (id != null ? id : UUID.randomUUID().toString()); this.query = query; this.name = name; this.description = description; } @Override @JsonIgnore public String getDefault() { StringBuilder defaultValue = new StringBuilder(); defaultValue.append(query); defaultValue.append(" "); defaultValue.append(name); defaultValue.append(" "); defaultValue.append(description); return defaultValue.toString(); } }