001/* 002 * JDrupes Builder 003 * Copyright (C) 2025 Michael N. Lipp 004 * 005 * This program is free software: you can redistribute it and/or modify 006 * it under the terms of the GNU Affero General Public License as 007 * published by the Free Software Foundation, either version 3 of the 008 * License, or (at your option) any later version. 009 * 010 * This program is distributed in the hope that it will be useful, 011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 013 * GNU Affero General Public License for more details. 014 * 015 * You should have received a copy of the GNU Affero General Public License 016 * along with this program. If not, see <https://www.gnu.org/licenses/>. 017 */ 018 019package org.jdrupes.builder.eclipse; 020 021import java.util.Objects; 022import org.jdrupes.builder.api.ResourceType; 023import org.jdrupes.builder.core.ResourceObject; 024 025/// Represents an eclipse configuration. 026/// 027public class DefaultEclipseConfiguration extends ResourceObject 028 implements EclipseConfiguration { 029 030 private final String projectName; 031 private final String eclipseAlias; 032 033 /// Initializes a new default eclipse configuration. 034 /// 035 /// @param type the type 036 /// @param projectName the project name 037 /// @param eclipseAlias the eclipse alias 038 /// 039 public DefaultEclipseConfiguration( 040 ResourceType<? extends EclipseConfiguration> type, 041 String projectName, String eclipseAlias) { 042 super(type); 043 this.projectName = Objects.requireNonNull(projectName); 044 this.eclipseAlias = Objects.requireNonNull(eclipseAlias); 045 } 046 047 @Override 048 public String projectName() { 049 return projectName; 050 } 051 052 @Override 053 public String eclipseAlias() { 054 return eclipseAlias; 055 } 056 057 @Override 058 public int hashCode() { 059 final int prime = 31; 060 int result = super.hashCode(); 061 result = prime * result + Objects.hash(projectName); 062 return result; 063 } 064 065 @Override 066 public boolean equals(Object obj) { 067 if (this == obj) { 068 return true; 069 } 070 if (!super.equals(obj)) { 071 return false; 072 } 073 if (!(obj instanceof DefaultEclipseConfiguration)) { 074 return false; 075 } 076 DefaultEclipseConfiguration other = (DefaultEclipseConfiguration) obj; 077 return Objects.equals(projectName, other.projectName); 078 } 079 080 /// To string. 081 /// 082 /// @return the string 083 /// 084 @Override 085 public String toString() { 086 return type().toString() + " " + eclipseAlias 087 + " (" + projectName + ")"; 088 } 089}