remove duplicate code
This commit is contained in:
parent
0ac97ec5d9
commit
e881e00b16
@ -1 +0,0 @@
|
|||||||
### Relevant Articles:
|
|
@ -1,59 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<artifactId>core-java-reflection-private-constructor</artifactId>
|
|
||||||
<name>core-java-reflection-private-constructor</name>
|
|
||||||
<packaging>jar</packaging>
|
|
||||||
|
|
||||||
<parent>
|
|
||||||
<groupId>com.baeldung.core-java-modules</groupId>
|
|
||||||
<artifactId>core-java-modules</artifactId>
|
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework</groupId>
|
|
||||||
<artifactId>spring-test</artifactId>
|
|
||||||
<version>${spring.version}</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.reflections</groupId>
|
|
||||||
<artifactId>reflections</artifactId>
|
|
||||||
<version>${reflections.version}</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<finalName>core-java-reflection-private-constructor</finalName>
|
|
||||||
<resources>
|
|
||||||
<resource>
|
|
||||||
<directory>src/main/resources</directory>
|
|
||||||
<filtering>true</filtering>
|
|
||||||
</resource>
|
|
||||||
</resources>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
|
||||||
<version>${maven-compiler-plugin.version}</version>
|
|
||||||
<configuration>
|
|
||||||
<source>${source.version}</source>
|
|
||||||
<target>${target.version}</target>
|
|
||||||
<compilerArgument>-parameters</compilerArgument>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<reflections.version>0.9.12</reflections.version>
|
|
||||||
<source.version>1.8</source.version>
|
|
||||||
<target.version>1.8</target.version>
|
|
||||||
<spring.version>5.3.4</spring.version>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
</project>
|
|
@ -1,8 +0,0 @@
|
|||||||
package com.baeldung.reflection;
|
|
||||||
|
|
||||||
public class PrivateConstructorClass {
|
|
||||||
|
|
||||||
private PrivateConstructorClass() {
|
|
||||||
System.out.println("Used the private constructor!");
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
package com.baeldung.reflection;
|
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
|
||||||
|
|
||||||
import org.junit.jupiter.api.Assertions;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
public class PrivateConstructorUnitTest {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void whenConstructorIsPrivate_thenInstanceSuccess() throws Exception {
|
|
||||||
Constructor<PrivateConstructorClass> pcc = PrivateConstructorClass.class.getDeclaredConstructor();
|
|
||||||
pcc.setAccessible(true);
|
|
||||||
PrivateConstructorClass privateConstructorInstance = pcc.newInstance();
|
|
||||||
Assertions.assertTrue(privateConstructorInstance instanceof PrivateConstructorClass);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user