From cf0711a1899bf74ea26eff495719afbfe11039bb Mon Sep 17 00:00:00 2001 From: Benjamin Bentmann Date: Sun, 23 Sep 2012 19:25:59 +0200 Subject: [PATCH] Removed superfluous RepositoryPolicy.set*() methods to simplify API --- .../aether/repository/RepositoryPolicy.java | 53 +------------------ .../impl/StubRemoteRepositoryManager.java | 12 +++-- 2 files changed, 10 insertions(+), 55 deletions(-) diff --git a/aether-api/src/main/java/org/eclipse/aether/repository/RepositoryPolicy.java b/aether-api/src/main/java/org/eclipse/aether/repository/RepositoryPolicy.java index 797ae815..05224a8a 100644 --- a/aether-api/src/main/java/org/eclipse/aether/repository/RepositoryPolicy.java +++ b/aether-api/src/main/java/org/eclipse/aether/repository/RepositoryPolicy.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010, 2011 Sonatype, Inc. + * Copyright (c) 2010, 2012 Sonatype, Inc. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -11,8 +11,7 @@ package org.eclipse.aether.repository; /** - * A policy controlling access to a repository. Note: Instances of this class are immutable and the exposed - * mutators return new objects rather than changing the current instance. + * A policy controlling access to a repository. */ public final class RepositoryPolicy { @@ -91,21 +90,6 @@ public final class RepositoryPolicy return enabled; } - /** - * Sets the enabled flag for the associated repository. - * - * @param enabled {@code true} if the repository should be contacted, {@code false} otherwise. - * @return The new policy, never {@code null}. - */ - public RepositoryPolicy setEnabled( boolean enabled ) - { - if ( this.enabled == enabled ) - { - return this; - } - return new RepositoryPolicy( enabled, updatePolicy, checksumPolicy ); - } - /** * Gets the update policy for locally cached data from the repository. * @@ -116,23 +100,6 @@ public final class RepositoryPolicy return updatePolicy; } - /** - * Sets the update policy for locally cached data from the repository. Well-known policies are - * {@link #UPDATE_POLICY_NEVER}, {@link #UPDATE_POLICY_ALWAYS}, {@link #UPDATE_POLICY_DAILY} and - * {@link #UPDATE_POLICY_INTERVAL} - * - * @param updatePolicy The update policy, may be {@code null}. - * @return The new policy, never {@code null}. - */ - public RepositoryPolicy setUpdatePolicy( String updatePolicy ) - { - if ( this.updatePolicy.equals( updatePolicy ) ) - { - return this; - } - return new RepositoryPolicy( enabled, updatePolicy, checksumPolicy ); - } - /** * Gets the policy for checksum validation. * @@ -143,22 +110,6 @@ public final class RepositoryPolicy return checksumPolicy; } - /** - * Sets the policy for checksum validation. Well-known policies are {@link #CHECKSUM_POLICY_FAIL}, - * {@link #CHECKSUM_POLICY_WARN} and {@link #CHECKSUM_POLICY_IGNORE}. - * - * @param checksumPolicy The checksum policy, may be {@code null}. - * @return The new policy, never {@code null}. - */ - public RepositoryPolicy setChecksumPolicy( String checksumPolicy ) - { - if ( this.checksumPolicy.equals( checksumPolicy ) ) - { - return this; - } - return new RepositoryPolicy( enabled, updatePolicy, checksumPolicy ); - } - @Override public String toString() { diff --git a/aether-impl/src/test/java/org/eclipse/aether/internal/impl/StubRemoteRepositoryManager.java b/aether-impl/src/test/java/org/eclipse/aether/internal/impl/StubRemoteRepositoryManager.java index 11f7edc2..0a111dca 100644 --- a/aether-impl/src/test/java/org/eclipse/aether/internal/impl/StubRemoteRepositoryManager.java +++ b/aether-impl/src/test/java/org/eclipse/aether/internal/impl/StubRemoteRepositoryManager.java @@ -39,15 +39,19 @@ class StubRemoteRepositoryManager { RepositoryPolicy policy = repository.getPolicy( snapshots ); - if ( !StringUtils.isEmpty( session.getChecksumPolicy() ) ) + String checksums = session.getChecksumPolicy(); + if ( StringUtils.isEmpty( checksums ) ) { - policy = policy.setChecksumPolicy( session.getChecksumPolicy() ); + checksums = policy.getChecksumPolicy(); } - if ( !StringUtils.isEmpty( session.getUpdatePolicy() ) ) + String updates = session.getUpdatePolicy(); + if ( StringUtils.isEmpty( updates ) ) { - policy = policy.setUpdatePolicy( session.getUpdatePolicy() ); + updates = policy.getUpdatePolicy(); } + policy = new RepositoryPolicy( policy.isEnabled(), updates, checksums ); + return policy; } -- GitLab