Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-172

Support alternate naming for boolean getters in ReflectionDBObject

    XMLWordPrintableJSON

Details

    • Icon: New Feature New Feature
    • Resolution: Won't Fix
    • Icon: Major - P3 Major - P3
    • None
    • 2.1
    • Codecs
    • None
    • java version "1.6.0_21"

    Description

      "is"-style getter is ignored by ReflectionObject.

      Domain class:
      --------------------------------------------------------

      package test;

      import com.mongodb.ReflectionDBObject;

      public class Something extends ReflectionDBObject {
      private String kk;
      private boolean bb;

      public Something(String kk, boolean bb)

      { this.kk = kk; this.bb = bb; }

      public String getKk()

      { return kk; }

      public void setKk(String kk)

      { this.kk = kk; }

      public boolean isBb()

      { return bb; }

      public void setBb(boolean bb)

      { this.bb = bb; }

      }

      Application class:
      --------------------------------------------------------

      package test;

      import com.mongodb.*;

      import java.net.UnknownHostException;

      public class BooleanGetterApp {
      public static void main(String[] args) {
      try

      { Mongo m = new Mongo("localhost", 27017); DB db = m.getDB("mydb"); DBCollection coll = db.getCollection("testCollection"); coll.drop(); Something something = new Something("kk", true); coll.save(something); DBObject dbObject = coll.findOne(); System.out.println(dbObject.toString()); }

      catch (UnknownHostException e)

      { e.printStackTrace(); }

      }
      }

      Application output:
      --------------------------------------------------------

      { "_id" :

      { "$oid" : "4cab3c5417066088cabbebf3"}

      , "Kk" : "kk"}

      – boolean value was ignored.

      Attachments

        Activity

          People

            Unassigned Unassigned
            ilya Ilya Brodotsky
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: