001/* 002 * Copyright 2012-2014 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.boot.cli.compiler.grape; 018 019import java.net.URI; 020 021import org.springframework.util.ObjectUtils; 022 023/** 024 * The configuration of a repository. 025 * 026 * @author Andy Wilkinson 027 */ 028public final class RepositoryConfiguration { 029 030 private final String name; 031 032 private final URI uri; 033 034 private final boolean snapshotsEnabled; 035 036 /** 037 * Creates a new {@code RepositoryConfiguration} instance. 038 * @param name The name of the repository 039 * @param uri The uri of the repository 040 * @param snapshotsEnabled {@code true} if the repository should enable access to 041 * snapshots, {@code false} otherwise 042 */ 043 public RepositoryConfiguration(String name, URI uri, boolean snapshotsEnabled) { 044 this.name = name; 045 this.uri = uri; 046 this.snapshotsEnabled = snapshotsEnabled; 047 } 048 049 /** 050 * Return the name of the repository. 051 * @return the repository name 052 */ 053 public String getName() { 054 return this.name; 055 } 056 057 @Override 058 public String toString() { 059 return "RepositoryConfiguration [name=" + this.name + ", uri=" + this.uri 060 + ", snapshotsEnabled=" + this.snapshotsEnabled + "]"; 061 } 062 063 /** 064 * Return the URI of the repository. 065 * @return the repository URI 066 */ 067 public URI getUri() { 068 return this.uri; 069 } 070 071 /** 072 * Return if the repository should enable access to snapshots. 073 * @return {@code true} if snapshot access is enabled 074 */ 075 public boolean getSnapshotsEnabled() { 076 return this.snapshotsEnabled; 077 } 078 079 @Override 080 public int hashCode() { 081 return ObjectUtils.nullSafeHashCode(this.name); 082 } 083 084 @Override 085 public boolean equals(Object obj) { 086 if (this == obj) { 087 return true; 088 } 089 if (obj == null) { 090 return false; 091 } 092 if (getClass() != obj.getClass()) { 093 return false; 094 } 095 RepositoryConfiguration other = (RepositoryConfiguration) obj; 096 return ObjectUtils.nullSafeEquals(this.name, other.name); 097 } 098 099}