Java tutorial
/** * Copyright 2008 Matthew Hillsdon * * 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. */ package net.hillsdon.reviki.configuration; import java.io.File; import java.util.List; import org.tmatesoft.svn.core.SVNURL; import com.google.common.base.Predicates; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; class PropertiesPerWikiConfiguration implements WikiConfiguration { private final PropertiesDeploymentConfiguration _deploymentConfiguration; private final String _wikiName; public PropertiesPerWikiConfiguration(final PropertiesDeploymentConfiguration deploymentConfiguration, final String wikiName) { _deploymentConfiguration = deploymentConfiguration; _wikiName = wikiName; } public File getSearchIndexDirectory() { return _deploymentConfiguration.getSearchIndexDirectory(_wikiName); } public List<File> getOtherSearchIndexDirectories() { Iterable<WikiConfiguration> otherWikis = Iterables.filter(_deploymentConfiguration.getWikis(), Predicates.not(Predicates.<WikiConfiguration>equalTo(this))); return Lists.newArrayList(Iterables.transform(otherWikis, WikiConfiguration.TO_SEARCH_INDEX_DIR)); } public void setUrl(final String location) { _deploymentConfiguration.setUrl(_wikiName, location); } public void setSVNUser(final String user) { _deploymentConfiguration.setSVNUser(_wikiName, user); } public void setSVNPassword(final String pass) { _deploymentConfiguration.setSVNPassword(_wikiName, pass); } public SVNURL getUrl() { return _deploymentConfiguration.getUrl(_wikiName); } public String getWikiName() { return _wikiName; } public void save() { _deploymentConfiguration.save(); } public boolean isComplete() { return _deploymentConfiguration.isComplete(_wikiName); } public boolean isEditable() { return _deploymentConfiguration.isEditable(); } public String getFixedBaseUrl() { return _deploymentConfiguration.getFixedBaseUrl(_wikiName); } public String getFixedBaseUrl(final String wikiName) { return _deploymentConfiguration.getFixedBaseUrl(wikiName); } public String getSVNUser() { return _deploymentConfiguration.getSVNUser(_wikiName); } public String getSVNPassword() { return _deploymentConfiguration.getSVNPassword(_wikiName); } @Override public boolean equals(final Object obj) { if (obj instanceof PropertiesPerWikiConfiguration) { String givenWikiName = ((PropertiesPerWikiConfiguration) obj)._wikiName; return _wikiName == null ? givenWikiName == null : _wikiName.equals(givenWikiName); } return false; } @Override public int hashCode() { return _deploymentConfiguration.getClass().hashCode() ^ (_wikiName == null ? 0 : _wikiName.hashCode()); } }