Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7828957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T10:33:39+00:00 2026-06-02T10:33:39+00:00

I have a serializable object with a TreeMap. Map<String, Dogs> dogsByNames = Maps.newTreeMap(); //

  • 0

I have a serializable object with a TreeMap.

Map<String, Dogs> dogsByNames = Maps.newTreeMap(); // guava style

So far, everything is fine.
Now it’s nessassary to ignore the case of the keys:

Map<String, Dogs> dogsByNames = Maps.newTreeMap(String.CASE_INSENSITIVE_ORDER);

This do not work because String.CASE_INSENSITIVE_ORDER isn’t serialzable:

com.google.gwt.user.client.rpc.SerializationException: Type
‘java.lang.String$CaseInsensitiveComparator’ was not included in the
set of types which can be serialized by this SerializationPolicy or
its Class object could not be loaded. For security purposes, this type
will not be serialized.: instance =
java.lang.String$CaseInsensitiveComparator@f26f68

So I create my own one:

private static abstract class MyComparator<T>
    implements
        Comparator<T>, // extends Ordering<T> do not work
        IsSerializable { // Serializable do not work
}

public static final MyComparator<String> CASE_INSENSITIVE_ORDER = new MyComparator<String>() {
    @Override
    public int compare(final String left, final String right) {
        if (null == left) {
            return (null == right) ? 0 : -1;
        } else if (null == right) {
            return 1;
        }
        return left.compareToIgnoreCase(right);
    }
};

But this still do not work.

Whats wrong?

Solution:

protected static class MyOrdering // no-private!!!
    extends
        Ordering<String>
    implements
        IsSerializable {
    @Override
    public int compare(final String left, final String right) {
        if (null == left) {
            return (null == right) ? 0 : -1;
        } else if (null == right) {
            return 1;
        }
        return left.compareToIgnoreCase(right);
    }
}

public static final Ordering<String> CASE_INSENSITIVE_ORDER = new MyOrdering();
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T10:33:45+00:00Added an answer on June 2, 2026 at 10:33 am

    The CASE_INSENSITIVE_ORDER you created is an anonymous class, which cannot be serialized in GWT. To make it GWT serializable, you need to

    1. Create a custom top-level class (like

      CaseInsensitiveOrder implements Comparator<..>, Serializable {
          ...
      }
      
    2. Create a constant CASE_INSENSITIVE_ORDER like you did.

    3. Create a custom field serializer for that class (CaseInsensitiveOrder_CustomFieldSerializer), which returns the CASE_INSENSITIVE_ORDER instance on deserialize().
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a serializable Message class that has a Data As Object property that
I have a non-serializable object that I would like to access from a separate
Let's suppose I have this object: [Serializable] public class MyClass { public int Age
I have a complex, [Serializable] object stored in session. I have Silverlight 3.0 islands
I have the following object: [Serializable] public class ExampleImage { public int ID {
I have a serializable object (ArrayList) within a Parcelable object. I am trying to
I have a Serializable object which is supposed to hold a java.awt.Image as its
I have been using the Serializable interface to pass an object from one activity
Say I have a couple of basic objects like so: [Serializable] public class Base
I have the following 2 objects: User and DomainUser User.java: package com.domain; import java.io.Serializable;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.