CacheKey( Plugin plugin, List<RemoteRepository> repositories, RepositorySystemSession session ) { groupId = plugin.getGroupId(); artifactId = plugin.getArtifactId(); version = plugin.getVersion(); workspace = RepositoryUtils.getWorkspace( session ); localRepo = session.getLocalRepository(); this.repositories = new ArrayList<>( repositories.size() ); for ( RemoteRepository repository : repositories ) { if ( repository.isRepositoryManager() ) { this.repositories.addAll( repository.getMirroredRepositories() ); } else { this.repositories.add( repository ); } } int hash = 17; hash = hash * 31 + groupId.hashCode(); hash = hash * 31 + artifactId.hashCode(); hash = hash * 31 + version.hashCode(); hash = hash * 31 + hash( workspace ); hash = hash * 31 + localRepo.hashCode(); hash = hash * 31 + RepositoryUtils.repositoriesHashCode( repositories ); this.hashCode = hash; }
@Override public boolean equals( Object obj ) { if ( this == obj ) { return true; } if ( !( obj instanceof CacheKey ) ) { return false; } CacheKey that = (CacheKey) obj; return eq( this.artifactId, that.artifactId ) && eq( this.groupId, that.groupId ) && eq( this.version, that.version ) && eq( this.localRepo, that.localRepo ) && eq( this.workspace, that.workspace ) && RepositoryUtils.repositoriesEquals( this.repositories, that.repositories ); }
public Key createKey( Plugin plugin, List<RemoteRepository> repositories, RepositorySystemSession session ) { return new CacheKey( plugin, repositories, session ); }