
br.com.objectos.jabuticava.Rg Maven / Gradle / Ivy
The newest version!
/*
* Copyright 2013 Objectos, Fábrica de Software LTDA.
*
* 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 br.com.objectos.jabuticava;
import java.time.LocalDate;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import br.com.objectos.core.lang.Strings;
/**
* @author [email protected] (Marcio Endo)
*/
public class Rg {
private final String numero;
private final String emissor;
private final LocalDate emissao;
private Rg(String numero, String emissor, LocalDate emissao) {
this.numero = numero;
this.emissor = emissor;
this.emissao = emissao;
}
public static Construtor construtor() {
return new Construtor();
}
public static Rg novo() {
return new Rg("", "", null);
}
public Rg comNumero(String numero) {
numero = Strings.nullToEmpty(numero);
return new Rg(numero, emissor, emissao);
}
public Rg comEmissor(String emissor) {
emissor = Strings.nullToEmpty(emissor);
return new Rg(numero, emissor, emissao);
}
public Rg comEmissao(LocalDate emissao) {
return new Rg(numero, emissor, emissao);
}
public String getNumero() {
return numero;
}
public String getEmissor() {
return emissor;
}
public LocalDate getEmissao() {
return emissao;
}
@Override
public String toString() {
return Stream.of(numero, emissor, emissao)
.filter(o -> o != null)
.map(Object::toString)
.collect(Collectors.joining(", "));
}
public static class Construtor {
private String numero;
private String emissor;
private LocalDate emissao;
public Rg novaInstancia() {
return new Rg(numero, emissor, emissao);
}
public Construtor numero(String numero) {
this.numero = numero;
return this;
}
public Construtor emissor(String emissor) {
this.emissor = emissor;
return this;
}
public Construtor emissao(LocalDate emissao) {
this.emissao = emissao;
return this;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy