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
import org.springframework.util.SerializationUtils; | |
import java.io.Serializable; | |
public class SerializationPuzzle { | |
public static void main(String[] args) { | |
B deserialized = (B) SerializationUtils.deserialize( | |
SerializationUtils.serialize(new B("alma"))); | |
System.out.println(deserialized.getText()); | |
} |
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
package at.liptakg.lombokdemo; | |
import lombok.Data; | |
import lombok.EqualsAndHashCode; | |
@Data | |
@EqualsAndHashCode(exclude="fooo") | |
public class SideEffectExample { | |
private String bar; | |
private String fooo; |
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
@Test | |
public void goodEquals() { | |
GoodEntityExample a = new GoodEntityExample("myfoo", 1, "excluded"); | |
GoodEntityExample b = new GoodEntityExample("myfoo", 1, "does not matter"); | |
assertThat( "Yeah. Works", a, is(b)); | |
} |
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
package at.liptakg.lombokdemo; | |
import lombok.AllArgsConstructor; | |
import lombok.Data; | |
import lombok.EqualsAndHashCode; | |
@Data | |
@EqualsAndHashCode(callSuper=false, exclude="name") | |
@AllArgsConstructor | |
public class GoodEntityExample extends POJO{ |
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
@Test | |
public void wrongEquals() { | |
WrongEntityExample a = new WrongEntityExample("myfoo", 1, "excluded"); | |
WrongEntityExample b = new WrongEntityExample("myfoo", 1, "does not matter"); | |
assertThat( "AAAAAAAA. Not equals :(", a, not(is(b))); | |
} |
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
package at.liptakg.lombokdemo; | |
public class POJO | |
{ | |
} |
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
package at.liptakg.lombokdemo; | |
import lombok.AllArgsConstructor; | |
import lombok.Data; | |
import lombok.EqualsAndHashCode; | |
@Data | |
@EqualsAndHashCode(callSuper=true, exclude="name") | |
@AllArgsConstructor | |
public class WrongEntityExample extends POJO{ |
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
package at.liptakg.lombokdemo; | |
public class POJO | |
{ | |
} | |
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
/** | |
Prints: | |
" " | |
"fdsajfklsdjalkf" | |
" " | |
"safd" | |
" " | |
"safsdfasdf" | |
" " |
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
@Configuration | |
public class RestTemplateConfiguration { | |
private static final String CUSTOM_HTTP_REQUEST_FACTORY_BEAN_NAME = "customHttpRequestFactory"; | |
/** | |
* See https://stackoverflow.com/a/36991745/337621 | |
* @return | |
*/ | |
@Bean(CUSTOM_HTTP_REQUEST_FACTORY_BEAN_NAME) | |
@ConfigurationProperties(prefix = "rest.connection") |
NewerOlder