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

org.catools.common.facker.provider.CFakerAddressProvider Maven / Gradle / Ivy

There is a newer version: 0.1.25
Show newest version
package org.catools.common.facker.provider;

import lombok.AllArgsConstructor;
import org.catools.common.facker.model.CRandomAddress;
import org.catools.common.facker.model.CRandomCity;
import org.catools.common.facker.model.CRandomStreetInfo;

@AllArgsConstructor
public class CFakerAddressProvider {
    private final CFakerCountryProvider country;
    private final CFakerStreetAddressProvider streetAddressProvider;

    public CRandomAddress getAny() {
        return getAny(country.getStateProviders().getAny().getState().getCode());
    }

    public CRandomAddress getAny(String stateCode) {
        CFakerStateProvider state = country.getStateProviders().getFirst(s -> s.getState().getCode().equalsIgnoreCase(stateCode));
        return getAny(stateCode, state.getRandomCity().getName());
    }

    public CRandomAddress getAny(String stateCode, String cityname) {
        CFakerStateProvider state = country.getStateProviders().getFirst(s -> s.getState().getCode().equalsIgnoreCase(stateCode));
        CRandomCity city = state.getCities().getFirst(s -> s.getName().equalsIgnoreCase(cityname));
        CRandomStreetInfo streetInfo = streetAddressProvider.getAny();
        return new CRandomAddress(country.getCountry(),
                state.getState(),
                city,
                streetInfo.getStreetName(),
                streetInfo.getStreetSuffix(),
                streetInfo.getStreetPrefix(),
                streetInfo.getStreetNumber(),
                streetInfo.getBuildingNumber());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy