Java tutorial
/* * Copyright 2016 Johannes Donath <johannesd@torchmind.com> * and other copyright owners as documented in the project's IP log. * * 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 com.torchmind.upm.bundle; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import javax.annotation.Nonnull; import java.util.Objects; /** * <strong>Basic Coordinate</strong> * * Provides a basic coordinate implementation which can be de-serialized using Jackson. * * @author <a href="mailto:johannesd@torchmind.com">Johannes Donath</a> */ public class BasicCoordinate implements Coordinate { private final String bundleId; private final String groupId; private final String type; private final String version; @JsonCreator public BasicCoordinate(@Nonnull @JsonProperty(value = "groupId", required = true) String groupId, @Nonnull @JsonProperty(value = "bundleId", required = true) String bundleId, @Nonnull @JsonProperty(value = "type", required = true) String type, @Nonnull @JsonProperty(value = "version", required = true) String version) { this.groupId = groupId; this.bundleId = bundleId; this.type = type; this.version = version; } /** * {@inheritDoc} */ @Nonnull @Override public String getBundleId() { return this.bundleId; } /** * {@inheritDoc} */ @Nonnull @Override public String getGroupId() { return this.groupId; } /** * {@inheritDoc} */ @Nonnull @Override public String getType() { return this.type; } /** * {@inheritDoc} */ @Nonnull @Override public String getVersion() { return this.version; } /** * {@inheritDoc} */ @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; BasicCoordinate that = (BasicCoordinate) o; return Objects.equals(this.groupId, that.groupId) && Objects.equals(this.bundleId, that.bundleId) && Objects.equals(this.type, that.type) && Objects.equals(this.version, that.version); } /** * {@inheritDoc} */ @Override public int hashCode() { return Objects.hash(this.groupId, this.bundleId, this.type, this.version); } /** * {@inheritDoc} */ @Override public String toString() { return this.groupId + "/" + this.bundleId + "/" + this.version + "/" + this.type; } }