The readResolve feature allows you to substitute another instance for the one created by readObject [Serialization, 3.7]. If the class of an object being deserialized defines a readResolve method with the proper declaration, this method is invoked on…
参考Java的官方tutorial和Doc整理如下. What is Enum An enum type is a special data type. It enables for a variable to be a set of predefined constants. Because they are constants, the names of an enum type's fields are in UPPERCASE letters. For example, you can…
在Java中,对Enum类型的序列化与其他对象类型的序列化有所不同,今天就来看看到底有什么不同.下面先来看下在Java中,我们定义的Enum在被编译之后是长成什么样子的. Java代码: Java代码 收藏代码 public enum FruitEnum { APPLE, ORAGE } 上面的代码定义了一个FruitEnum类型,是最简单形式的,下面我们来看看编译之后的字节码. 字节码: Java代码 收藏代码 public final class com.taobao.tianxiao.Fr…
Principle Strings are poor substitutes for other value types. Such as int, float or BigInteger. Strings are poor substitutes for enum types. As discussed in Item 30. Strings are poor substitutes for aggregate types. A better approach is simply to wri…
枚举类在Javac中是被当作类来看待的. An enum type is implicitly final unless it contains at least one enum constant that has a class body. 举例如下: enum EnumTest { MON(1), TUE(2), WED(3), THU(4), FRI(5), SAT(6) { @Override public boolean isRest() { return true; } }, SU…
We have created our first Entity Data Model for School database in the previous section. The visual designer of EDM does not display all the objects it creats. It only display entities which are mapped to the database tables and views. Model Browser …
Background C++ is one of the main development languages used by many of Google's open-source projects. As every C++ programmer knows, the language has many powerful features, but this power brings with it complexity, which in turn can make code more…
Hi guys, I am happy to tell you that I am moving to the open source world. And Java is the 1st language I have chosen for this migration. It's a nice chance to read some great books like "Effective Java 2nd Edition" and share the note for what I…
Npgsql 是基于ADO.NET 的PostgreSQL 数据驱动. Npgsql 官方 已经提供C# 数据类型与PostgreSQL数据类型的对应映射 地址: http://www.npgsql.org/doc/types.html Type mappings Type mappings when reading values sent from the backend PostgreSQL type Default .NET type Provider-specific type Othe…
Enumerated type is a type whose legal values consist of a fixed set of constants, such as the seasons of the year. // The int enum pattern - severely deficient! public static final int APPLE_FUJI = 0; public static final int APPLE_PIPPIN = 1; public…
Bit fields is used for passing around sets of constants. Such as // Bit field enumeration constants - OBSOLETE! public class Text { public static final int STYLE_BOLD = 1 << 0; // 1 public static final int STYLE_ITALIC = 1 << 1; // 2 public st…
Wrong practice: Putting sets into an array indexed by the type's ordinal /** * Added demo for the "Use EnumMap instead of ordinal indexing". */ package com.effectivejava.EnumAnnotations; /** * @author Kaibo * */ public class Herb { public enum T…
Advantage Disadvantage Enum types Clarity Safety Ease of maintenance. None extensibility Typesafe enum pattern(Interfaces to emulate extensible enums) Extensibility No good way to enumerate all of the elements of a base type and its extension. Extens…
Principle Choose method names carefully. Don't go overboard in providing convenience methods. Avoid long parameter lists. Break the method up into multiple methods. Such as sublist element of List interface. Create helper classes to hold groups of pa…
Principle The presence of the synchronized modifier in a method declaration is an implementation detail, not a part of its exported API. To enable safe concurrent use, a class must clearly document what level of thread safety it supports. Immutable •…
Interfaces There are a number of situations in software engineering when it is important for disparate groups of programmers to agree to a "contract" that spells out how their software interacts. Each group should be able to write their code wit…
http://www.entityframeworktutorial.net/model-browser-in-entity-framework.aspx We have created our first Entity Data Model for School database in the previous section. The visual designer of EDM does not display all the objects it creats. It only disp…
When everything is an object, nothing is. So, there are a few ways you could parse that, but for the purposes of this article, this is all to say: sometimes it's nice to be able to drop down to the C layer of things. Yes--that non-objective part of o…
8.1. Class Declarations 8.1.1. Class Modifiers 8.1.1.1. abstract Classes 8.1.1.2. final Classes 8.1.1.3. strictfp Classes 8.1.2. Generic Classes and Type Parameters 8.1.3. Inner Classes and Enclosing Instances 8.1.4. Superclasses and Subclasses 8.1.5…
Many new learners can not make sure the usage scenarios of readonly and const keywords. In my opinion, the main reason of using readonly keyword is the efficiency. but in most occasions, efficiency isn’t treated as the high level. so I’m willing to u…
Following on/off features are defined in DeserializationConfig.Feature (Jackson 1.x) or DeserializationFeature (Jackson 2.x): ACCEPT_EMPTY_STRING_AS_NULL_OBJECT (default: false) (since 1.8) Determines whether empty JSON String value is accepted as nu…
Understanding how Java code is compiled into byte code and executed on a Java Virtual Machine (JVM) is critical because it helps you understand what is happening as your program executes. This understanding not only ensures that language features mak…