Skip to content

Commit

Permalink
BasicHelperNG / BasicWrapperNG with no serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
fugerit79 committed Mar 8, 2024
1 parent c57acf0 commit 80f91a2
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- BasicHelperNG / BasicWrapperNG with no serialization

## [8.5.1] - 2024-03-08

### Added
Expand Down
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 );
}

}
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 );
}

}
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
package test.org.fugerit.java.core.db.dao.daogen;

import java.io.NotSerializableException;
import java.io.Serializable;
import java.math.BigDecimal;

import org.fugerit.java.core.db.dao.DAOException;
import org.fugerit.java.core.db.dao.DAORuntimeException;
import org.fugerit.java.core.db.dao.FieldList;
import org.fugerit.java.core.db.daogen.BasicDaoResult;
import org.fugerit.java.core.db.daogen.BasicDataFacade;
import org.fugerit.java.core.db.daogen.BasicWrapper;
import org.fugerit.java.core.db.daogen.CloseableDAOContextSC;
import org.fugerit.java.core.db.daogen.DataEntityInfo;
import org.fugerit.java.core.db.daogen.DataEntityUtils;
import org.fugerit.java.core.db.daogen.QueryHelper;
import org.fugerit.java.core.db.daogen.*;
import org.fugerit.java.core.function.SafeFunction;
import org.junit.Assert;
import org.junit.Test;
Expand Down Expand Up @@ -87,6 +82,12 @@ public void testBasicDataFacade2() {
log.info( "test 3 : {}", HELPER.fullSerializationTest( userWrapper ) );
userWrapper.wrapModel( userTest );
Assert.assertThrows( UnsupportedOperationException.class , () -> BasicWrapper.throwUnsupported( "message" ) );
// wrapper ng
BasicWrapperNG<ModelUser> userWrapperNG = new BasicWrapperNG<>( userTest );
log.info( "test 1 : {}", userWrapperNG.unwrap() );
log.info( "test 2 : {}", userWrapperNG.unwrapModel() );
Assert.assertThrows(NotSerializableException.class, () -> HELPER.fullSerializationTest( userWrapperNG ));
userWrapper.wrapModel( userTest );
// test DataEntityUtils
DataEntityUtils.unwrap( facade );
Assert.assertThrows( DAOException.class , () -> DataEntityUtils.unwrap( userTest ) );
Expand Down

0 comments on commit 80f91a2

Please sign in to comment.