io.polygenesis.core.AbstractNameablePackageable Maven / Gradle / Ivy
/*-
* ==========================LICENSE_START=================================
* PolyGenesis Platform
* ========================================================================
* Copyright (C) 2015 - 2019 Christos Tsakostas, OREGOR LTD
* ========================================================================
* 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.
* ===========================LICENSE_END==================================
*/
package io.polygenesis.core;
import io.polygenesis.commons.assertion.Assertion;
import io.polygenesis.commons.valueobjects.ObjectName;
import io.polygenesis.commons.valueobjects.PackageName;
import java.util.Objects;
/**
* The type Abstract nameable packageable.
*
* @author Christos Tsakostas
*/
public abstract class AbstractNameablePackageable implements Nameable, Packageable {
// ===============================================================================================
// STATE
// ===============================================================================================
private ObjectName objectName;
private PackageName packageName;
// ===============================================================================================
// CONSTRUCTOR(S)
// ===============================================================================================
/**
* Instantiates a new Abstract nameable packageable.
*
* @param objectName the object name
* @param packageName the package name
*/
public AbstractNameablePackageable(ObjectName objectName, PackageName packageName) {
setObjectName(objectName);
setPackageName(packageName);
}
// ===============================================================================================
// GETTERS
// ===============================================================================================
// ===============================================================================================
// GUARDS
// ===============================================================================================
/**
* Sets object name.
*
* @param objectName the object name
*/
private void setObjectName(ObjectName objectName) {
Assertion.isNotNull(objectName, "objectName is required");
this.objectName = objectName;
}
/**
* Sets package name.
*
* @param packageName the package name
*/
private void setPackageName(PackageName packageName) {
Assertion.isNotNull(packageName, "packageName is required");
this.packageName = packageName;
}
// ===============================================================================================
// OVERRIDES
// ===============================================================================================
@Override
public ObjectName getObjectName() {
return objectName;
}
@Override
public PackageName getPackageName() {
return packageName;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
AbstractNameablePackageable that = (AbstractNameablePackageable) o;
return Objects.equals(objectName, that.objectName)
&& Objects.equals(packageName, that.packageName);
}
@Override
public int hashCode() {
return Objects.hash(objectName, packageName);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy