Quantcast
Channel: OmniFaces & JSF Fans
Viewing all articles
Browse latest Browse all 74

[OmniFaces utilities 2.4] Check if the given object is serializable

$
0
0

[OmniFaces utilities] The isSerializable() method returns true if the given object is serializable.

Method:
Usage:

Example 1 - test Object:

import org.omnifaces.util.Utils;
...
Utils.isSerializable(new Object()); // return false

Example 2 - test two classes

// Serializable class
public class ShopingCart implements Serializable {
 ...    
}

// NOT Serializable class
public class Item {
 ...    
}

Utils.isSerializable(new ShopingCart()); // return true
Utils.isSerializable(new Item()); // return false


Viewing all articles
Browse latest Browse all 74

Trending Articles