question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Immutable implementation detection

See original GitHub issue

copy from https://github.com/arnaudroger/SimpleFlatMapper/issues/574#issuecomment-462845517

This is very nice, thanks for the quick response. Unfortunately, now I see I misread the issue. What I would like to do is to use the interface and have sfm use the immutable implementation automatically:

@Value.Immutable
public interface ReallyUsefulInformation {
    String info();
}

public interface ReallyUsefulInformationDao {
    @SqlQuery("...")
    ReallyUsefulInformation getReallyUsefulInformation();
}

Maybe I could help you build sfm-immutables to actually detect @Value.Immutable and use the generated immutable class?

This is the error I get:

org.simpleflatmapper.map.MapperBuildingException: Could not find eligible property for 'info' on  interface ...ReallyUsefulInformation not found  See https://github.com/arnaudroger/SimpleFlatMapper/wiki/Errors_PROPERTY_NOT_FOUND
	at org.simpleflatmapper.map.error.RethrowMapperBuilderErrorHandler.propertyNotFound(RethrowMapperBuilderErrorHandler.java:26)
	at org.simpleflatmapper.map.mapper.PropertyMappingsBuilder._addProperty(PropertyMappingsBuilder.java:105)
	at org.simpleflatmapper.map.mapper.PropertyMappingsBuilder.addProperty(PropertyMappingsBuilder.java:69)
	at org.simpleflatmapper.map.mapper.DefaultConstantSourceMapperBuilder.addMapping(DefaultConstantSourceMapperBuilder.java:159)
	at org.simpleflatmapper.map.mapper.SetRowMapperBuilderImpl.addMapping(SetRowMapperBuilderImpl.java:206)
	at org.simpleflatmapper.map.mapper.MapperBuilder.addMapping(MapperBuilder.java:142)
	at org.simpleflatmapper.map.mapper.MapperBuilder.addMapping(MapperBuilder.java:152)
	at org.simpleflatmapper.jdbc.JdbcMapperFactory$SetRowMapperFactory.newInstance(JdbcMapperFactory.java:344)
	at org.simpleflatmapper.jdbc.JdbcMapperFactory$SetRowMapperFactory.newInstance(JdbcMapperFactory.java:332)
	at org.simpleflatmapper.map.mapper.DynamicSetRowMapper.getMapper(DynamicSetRowMapper.java:104)
	at org.simpleflatmapper.jdbc.JdbcMapperFactory$DynamicJdbcSetRowMapper.getMapper(JdbcMapperFactory.java:299)
	at org.simpleflatmapper.jdbi3.DynamicRowMapper.specialize(DynamicRowMapper.java:25)
	at org.jdbi.v3.core.result.ResultSetResultIterator.<init>(ResultSetResultIterator.java:38)
	at org.jdbi.v3.core.result.ResultIterable.lambda$of$0(ResultIterable.java:53)
	at org.jdbi.v3.core.result.ResultIterable.findFirst(ResultIterable.java:116)
	at org.jdbi.v3.sqlobject.statement.internal.ResultReturner$CollectedResultReturner.mappedResult(ResultReturner.java:276)
	at org.jdbi.v3.sqlobject.statement.internal.SqlQueryHandler.lambda$configureReturner$0(SqlQueryHandler.java:54)
	at org.jdbi.v3.sqlobject.statement.internal.CustomizingStatementHandler.invoke(CustomizingStatementHandler.java:155)
	at org.jdbi.v3.sqlobject.statement.internal.SqlQueryHandler.invoke(SqlQueryHandler.java:26)
	at org.jdbi.v3.sqlobject.SqlObjectFactory.lambda$null$13(SqlObjectFactory.java:158)
	at org.jdbi.v3.core.internal.JdbiThreadLocals.invokeInContext(JdbiThreadLocals.java:27)
	at org.jdbi.v3.core.LazyHandleSupplier.lambda$invokeInContext$1(LazyHandleSupplier.java:72)
	at org.jdbi.v3.core.internal.JdbiThreadLocals.invokeInContext(JdbiThreadLocals.java:27)
	at org.jdbi.v3.core.LazyHandleSupplier.invokeInContext(LazyHandleSupplier.java:71)
	at org.jdbi.v3.sqlobject.SqlObjectFactory.lambda$createInvocationHandler$14(SqlObjectFactory.java:157)
	at org.jdbi.v3.core.OnDemandExtensions.invoke(OnDemandExtensions.java:76)
	at org.jdbi.v3.core.OnDemandExtensions.lambda$null$0(OnDemandExtensions.java:63)
	at org.jdbi.v3.core.internal.JdbiThreadLocals.invokeInContext(JdbiThreadLocals.java:27)
	at org.jdbi.v3.core.OnDemandExtensions.lambda$null$1(OnDemandExtensions.java:62)
	at org.jdbi.v3.core.Jdbi.withExtension(Jdbi.java:439)
	at org.jdbi.v3.core.OnDemandExtensions.lambda$create$2(OnDemandExtensions.java:61)
	at com.sun.proxy.$Proxy42.getReallyUsefulInformation(Unknown Source)
	at ...ReallyUsefulInformationFacade.getReallyUsefulInformation(ReallyUsefulInformationFacade.java:18)
...

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
arnaudrogercommented, Feb 12, 2019

So the way I see it implemented would be in the reflection service before returning the objectmetadata it would check for the annotation using reflection and try to figure out the immutable class and return an objectmetadata on that one. I should be able to do that quickly the annotations are their at runtime. There is also a style annotation to check that can override the name. If the immutable is not public the we fall back on the interface.

0reactions
arnaudrogercommented, Feb 14, 2019

great! thanks for the feedback!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Immutable objects
An immutable implementation class implements abstract attribute accessors for scalar primitive and object reference types, with special support provided for ...
Read more >
Testing Object's Immutability: Is This a Good Idea?
NOTE: Immutability must be tested against each class behavior, and should be included in the same tests we usually do to guarantee the...
Read more >
Class invariants, immutability, and testing
Class invariants and defensive copying. • Immutability. • Testing and coverage. • Testing for complex environments. • Implementation testing with assertions ...
Read more >
How do I identify immutable objects in Java - Stack Overflow
There is no reliable way to detect if a class is immutable. This is because there are so many ways a property of...
Read more >
Enforcing Immutability - Rangle.io : Angular Training
We cheated a little in the previous example. We told Angular that all of our inputs, including the actor object, were immutable objects,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found