mardi 4 juin 2019

Calling a private static void method

I have a private static void method namely convertToIp in the class EllaDtoConverter that has a private constructor. If I try to create an instance of the class, it throws an exception. The code is provided,

public final class EllaDtoConverter {

    private EllaDtoConverter() {
        throw new PrivateConstructorException();
    }

private static void convertToIp( final IrisBo irisBo, EllaRequestDto request ) {

        if( !isNull( irisBo.getDevice() ) ) {
            request.setIp( irisBo.getDevice().getIpAddress() );
        }
    }

    // ..... some code 
}

I can create the instances of the IrisBo and the EllaRequestDto and pass inside the method. Do I have an option to call the convertToIp method outside from another class (even with using the reflection)?





Aucun commentaire:

Enregistrer un commentaire