com.force.i18n.LocaleAttributesUtilBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of grammaticus Show documentation
Show all versions of grammaticus Show documentation
Localization Framework that allows grammatically correct renaming of nouns
/*
* Copyright (c) 2017, salesforce.com, inc.
* All rights reserved.
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
package com.force.i18n;
import java.util.List;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
/**
* Builder for a {@link LocaleAttributesUtil} instance built from {@link LocaleInfo} instances. This is mostly syntactic sugar to make the
* DefaultLocaleAttributesUtil#createLocaleAttributesUtil() easier to read.
* @author jared.pearson
*/
class LocaleAttributesUtilBuilder {
private final ImmutableList.Builder localeInfoListBuilder = ImmutableList.builder();
/**
* Adds a new local info instances to the config.
* @return this
*/
public LocaleAttributesUtilBuilder add(LocaleInfoBuilder localeInfoBuilder) {
Preconditions.checkArgument(localeInfoBuilder != null, "localeInfoBuilder should not be null");
final LocaleInfo localeInfo = localeInfoBuilder.build();
assert localeInfo != null;
localeInfoListBuilder.add(localeInfo);
return this;
}
/**
* Builds a new {@link LocaleAttributesUtil} instance.
*/
public LocaleAttributesUtil build() {
final List localeInfoList = localeInfoListBuilder.build();
return new SimpleLocaleAttributesUtil(localeInfoList);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy