-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BasicHelperNG / BasicWrapperNG with no serialization
- Loading branch information
Showing
6 changed files
with
90 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
fj-core/src/main/java/org/fugerit/java/core/db/daogen/BasicHelperNG.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.fugerit.java.core.db.daogen; | ||
|
||
public class BasicHelperNG { | ||
|
||
public void throwUnsupported( String message ) { | ||
BasicHelper.throwUnsupported( message ); | ||
} | ||
|
||
} |
39 changes: 39 additions & 0 deletions
39
fj-core/src/main/java/org/fugerit/java/core/db/daogen/BasicWrapperNG.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package org.fugerit.java.core.db.daogen; | ||
|
||
import org.fugerit.java.core.lang.helpers.Wrapper; | ||
import org.fugerit.java.core.lang.helpers.WrapperHelper; | ||
|
||
public class BasicWrapperNG<T> implements Wrapper<T> { | ||
|
||
public static void throwUnsupported( String message ) { | ||
BasicHelper.throwUnsupported( message ); | ||
} | ||
|
||
private T wrapped; | ||
|
||
@Override | ||
public T unwrapModel() { | ||
return wrapped; | ||
} | ||
|
||
@Override | ||
public void wrapModel(T wrapped) { | ||
this.wrapped = wrapped; | ||
} | ||
|
||
public BasicWrapperNG(T wrapped) { | ||
super(); | ||
this.wrapped = wrapped; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return this.getClass().getSimpleName()+"[wraps:"+unwrapModel().toString()+"]"; | ||
} | ||
|
||
@Override | ||
public T unwrap() { | ||
return WrapperHelper.unwrap( this.wrapped ); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
fj-core/src/test/java/test/org/fugerit/java/core/db/dao/daogen/TestBasicWrapperNG.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package test.org.fugerit.java.core.db.dao.daogen; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import org.fugerit.java.core.db.daogen.BasicWrapperNG; | ||
import org.fugerit.java.core.function.SafeFunction; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import test.org.fugerit.java.BasicTest; | ||
import test.org.fugerit.java.core.db.dao.ModelUser; | ||
|
||
import java.io.NotSerializableException; | ||
|
||
@Slf4j | ||
public class TestBasicWrapperNG { | ||
|
||
private static final BasicTest HELPER = new BasicTest(); | ||
|
||
@Test | ||
public void testBasicDataFacade2() { | ||
SafeFunction.apply( () -> { | ||
ModelUser userTest = new ModelUser(); | ||
// wrapper ng | ||
BasicWrapperNG<ModelUser> userWrapperNG = new BasicWrapperNG<>( userTest ); | ||
log.info( "test 1 : {}", userWrapperNG.unwrap() ); | ||
log.info( "test 2 : {}", userWrapperNG.unwrapModel() ); | ||
log.info( "test 3 : {}", userWrapperNG ); | ||
Assert.assertThrows( UnsupportedOperationException.class, () -> BasicWrapperNG.throwUnsupported( "test 1" ) ); | ||
Assert.assertThrows(NotSerializableException.class, () -> HELPER.fullSerializationTest( userWrapperNG )); | ||
} ); | ||
} | ||
|
||
} |