All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.force.i18n.LocaleAttributesUtilBuilder Maven / Gradle / Ivy

There is a newer version: 1.2.30
Show newest version
/* 
 * 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