google-nomulus/java/google/registry/model/pricing/PremiumPricingEngine.java
shikhman f76bc70f91 Preserve test logs and test summary output for Kokoro CI runs
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=135494972
2016-10-14 16:57:43 -04:00

84 lines
2.7 KiB
Java

// Copyright 2016 The Nomulus Authors. All Rights Reserved.
//
// 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 google.registry.model.pricing;
import com.google.common.base.Optional;
import org.joda.money.Money;
import org.joda.time.DateTime;
/**
* A plugin interface for premium pricing engines.
*
* <p>A premium pricing engine is responsible solely for determining whether a given label is
* premium or not, and if it is, how much it should cost.
*/
public interface PremiumPricingEngine {
/**
* Returns the prices for the given fully qualified domain name at the given time.
*
* <p>Note that the fullyQualifiedDomainName must only contain a single part left of the TLD, i.e.
* subdomains are not allowed, but multi-part TLDs are.
*/
public DomainPrices getDomainPrices(String fullyQualifiedDomainName, DateTime priceTime);
/**
* A class containing information on premium prices for a specific domain name.
*
* <p>Any implementation of PremiumPricingEngine is responsible for determining all of these.
*/
public static class DomainPrices {
private boolean isPremium;
// TODO(b/26901539): Refactor return values to support an arbitrary list of costs for each of
// create, renew, restore, and transfer.
private Money createCost;
private Money renewCost;
private Optional<String> feeClass;
static DomainPrices create(
boolean isPremium,
Money createCost,
Money renewCost,
Optional<String> feeClass) {
DomainPrices instance = new DomainPrices();
instance.isPremium = isPremium;
instance.createCost = createCost;
instance.renewCost = renewCost;
instance.feeClass = feeClass;
return instance;
}
/** Returns whether the domain is premium. */
public boolean isPremium() {
return isPremium;
}
/** Returns the cost to create the domain. */
public Money getCreateCost() {
return createCost;
}
/** Returns the cost to renew the domain. */
public Money getRenewCost() {
return renewCost;
}
/** Returns the fee class of the cost (used for the Fee extension). */
public Optional<String> getFeeClass() {
return feeClass;
}
}
}