Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: third_party/protobuf/java/core/src/main/java/com/google/protobuf/Internal.java

Issue 2495533002: third_party/protobuf: Update to HEAD (83d681ee2c) (Closed)
Patch Set: Make chrome settings proto generated file a component Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Protocol Buffers - Google's data interchange format 1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2008 Google Inc. All rights reserved. 2 // Copyright 2008 Google Inc. All rights reserved.
3 // https://developers.google.com/protocol-buffers/ 3 // https://developers.google.com/protocol-buffers/
4 // 4 //
5 // Redistribution and use in source and binary forms, with or without 5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are 6 // modification, are permitted provided that the following conditions are
7 // met: 7 // met:
8 // 8 //
9 // * Redistributions of source code must retain the above copyright 9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer. 10 // notice, this list of conditions and the following disclaimer.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 * @author kenton@google.com (Kenton Varda) 53 * @author kenton@google.com (Kenton Varda)
54 */ 54 */
55 public final class Internal { 55 public final class Internal {
56 56
57 private Internal() {} 57 private Internal() {}
58 58
59 static final Charset UTF_8 = Charset.forName("UTF-8"); 59 static final Charset UTF_8 = Charset.forName("UTF-8");
60 static final Charset ISO_8859_1 = Charset.forName("ISO-8859-1"); 60 static final Charset ISO_8859_1 = Charset.forName("ISO-8859-1");
61 61
62 /** 62 /**
63 * Throws an appropriate {@link NullPointerException} if the given objects is {@code null}.
64 */
65 static <T> T checkNotNull(T obj, String message) {
66 if (obj == null) {
67 throw new NullPointerException(message);
68 }
69 return obj;
70 }
71
72 /**
63 * Helper called by generated code to construct default values for string 73 * Helper called by generated code to construct default values for string
64 * fields. 74 * fields.
65 * <p> 75 * <p>
66 * The protocol compiler does not actually contain a UTF-8 decoder -- it 76 * The protocol compiler does not actually contain a UTF-8 decoder -- it
67 * just pushes UTF-8-encoded text around without touching it. The one place 77 * just pushes UTF-8-encoded text around without touching it. The one place
68 * where this presents a problem is when generating Java string literals. 78 * where this presents a problem is when generating Java string literals.
69 * Unicode characters in the string literal would normally need to be encoded 79 * Unicode characters in the string literal would normally need to be encoded
70 * using a Unicode escape sequence, which would require decoding them. 80 * using a Unicode escape sequence, which would require decoding them.
71 * To get around this, protoc instead embeds the UTF-8 bytes into the 81 * To get around this, protoc instead embeds the UTF-8 bytes into the
72 * generated code and leaves it to the runtime library to decode them. 82 * generated code and leaves it to the runtime library to decode them.
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 * possible. Does not support null elements. 614 * possible. Does not support null elements.
605 */ 615 */
606 public static interface IntList extends ProtobufList<Integer> { 616 public static interface IntList extends ProtobufList<Integer> {
607 617
608 /** 618 /**
609 * Like {@link #get(int)} but more efficient in that it doesn't box the retu rned value. 619 * Like {@link #get(int)} but more efficient in that it doesn't box the retu rned value.
610 */ 620 */
611 int getInt(int index); 621 int getInt(int index);
612 622
613 /** 623 /**
614 * Like {@link #add(Integer)} but more efficient in that it doesn't box the element. 624 * Like {@link #add(Object)} but more efficient in that it doesn't box the e lement.
615 */ 625 */
616 void addInt(int element); 626 void addInt(int element);
617 627
618 /** 628 /**
619 * Like {@link #set(int, Integer)} but more efficient in that it doesn't box the element. 629 * Like {@link #set(int, Object)} but more efficient in that it doesn't box the element.
620 */ 630 */
621 int setInt(int index, int element); 631 int setInt(int index, int element);
622 632
623 /** 633 /**
624 * Returns a mutable clone of this list with the specified capacity. 634 * Returns a mutable clone of this list with the specified capacity.
625 */ 635 */
626 @Override 636 @Override
627 IntList mutableCopyWithCapacity(int capacity); 637 IntList mutableCopyWithCapacity(int capacity);
628 } 638 }
629 639
630 /** 640 /**
631 * A {@link java.util.List} implementation that avoids boxing the elements int o Booleans if 641 * A {@link java.util.List} implementation that avoids boxing the elements int o Booleans if
632 * possible. Does not support null elements. 642 * possible. Does not support null elements.
633 */ 643 */
634 public static interface BooleanList extends ProtobufList<Boolean> { 644 public static interface BooleanList extends ProtobufList<Boolean> {
635 645
636 /** 646 /**
637 * Like {@link #get(int)} but more efficient in that it doesn't box the retu rned value. 647 * Like {@link #get(int)} but more efficient in that it doesn't box the retu rned value.
638 */ 648 */
639 boolean getBoolean(int index); 649 boolean getBoolean(int index);
640 650
641 /** 651 /**
642 * Like {@link #add(Boolean)} but more efficient in that it doesn't box the element. 652 * Like {@link #add(Object)} but more efficient in that it doesn't box the e lement.
643 */ 653 */
644 void addBoolean(boolean element); 654 void addBoolean(boolean element);
645 655
646 /** 656 /**
647 * Like {@link #set(int, Boolean)} but more efficient in that it doesn't box the element. 657 * Like {@link #set(int, Object)} but more efficient in that it doesn't box the element.
648 */ 658 */
649 boolean setBoolean(int index, boolean element); 659 boolean setBoolean(int index, boolean element);
650 660
651 /** 661 /**
652 * Returns a mutable clone of this list with the specified capacity. 662 * Returns a mutable clone of this list with the specified capacity.
653 */ 663 */
654 @Override 664 @Override
655 BooleanList mutableCopyWithCapacity(int capacity); 665 BooleanList mutableCopyWithCapacity(int capacity);
656 } 666 }
657 667
658 /** 668 /**
659 * A {@link java.util.List} implementation that avoids boxing the elements int o Longs if 669 * A {@link java.util.List} implementation that avoids boxing the elements int o Longs if
660 * possible. Does not support null elements. 670 * possible. Does not support null elements.
661 */ 671 */
662 public static interface LongList extends ProtobufList<Long> { 672 public static interface LongList extends ProtobufList<Long> {
663 673
664 /** 674 /**
665 * Like {@link #get(int)} but more efficient in that it doesn't box the retu rned value. 675 * Like {@link #get(int)} but more efficient in that it doesn't box the retu rned value.
666 */ 676 */
667 long getLong(int index); 677 long getLong(int index);
668 678
669 /** 679 /**
670 * Like {@link #add(Long)} but more efficient in that it doesn't box the ele ment. 680 * Like {@link #add(Object)} but more efficient in that it doesn't box the e lement.
671 */ 681 */
672 void addLong(long element); 682 void addLong(long element);
673 683
674 /** 684 /**
675 * Like {@link #set(int, Long)} but more efficient in that it doesn't box th e element. 685 * Like {@link #set(int, Object)} but more efficient in that it doesn't box the element.
676 */ 686 */
677 long setLong(int index, long element); 687 long setLong(int index, long element);
678 688
679 /** 689 /**
680 * Returns a mutable clone of this list with the specified capacity. 690 * Returns a mutable clone of this list with the specified capacity.
681 */ 691 */
682 @Override 692 @Override
683 LongList mutableCopyWithCapacity(int capacity); 693 LongList mutableCopyWithCapacity(int capacity);
684 } 694 }
685 695
686 /** 696 /**
687 * A {@link java.util.List} implementation that avoids boxing the elements int o Doubles if 697 * A {@link java.util.List} implementation that avoids boxing the elements int o Doubles if
688 * possible. Does not support null elements. 698 * possible. Does not support null elements.
689 */ 699 */
690 public static interface DoubleList extends ProtobufList<Double> { 700 public static interface DoubleList extends ProtobufList<Double> {
691 701
692 /** 702 /**
693 * Like {@link #get(int)} but more efficient in that it doesn't box the retu rned value. 703 * Like {@link #get(int)} but more efficient in that it doesn't box the retu rned value.
694 */ 704 */
695 double getDouble(int index); 705 double getDouble(int index);
696 706
697 /** 707 /**
698 * Like {@link #add(Double)} but more efficient in that it doesn't box the e lement. 708 * Like {@link #add(Object)} but more efficient in that it doesn't box the e lement.
699 */ 709 */
700 void addDouble(double element); 710 void addDouble(double element);
701 711
702 /** 712 /**
703 * Like {@link #set(int, Double)} but more efficient in that it doesn't box the element. 713 * Like {@link #set(int, Object)} but more efficient in that it doesn't box the element.
704 */ 714 */
705 double setDouble(int index, double element); 715 double setDouble(int index, double element);
706 716
707 /** 717 /**
708 * Returns a mutable clone of this list with the specified capacity. 718 * Returns a mutable clone of this list with the specified capacity.
709 */ 719 */
710 @Override 720 @Override
711 DoubleList mutableCopyWithCapacity(int capacity); 721 DoubleList mutableCopyWithCapacity(int capacity);
712 } 722 }
713 723
714 /** 724 /**
715 * A {@link java.util.List} implementation that avoids boxing the elements int o Floats if 725 * A {@link java.util.List} implementation that avoids boxing the elements int o Floats if
716 * possible. Does not support null elements. 726 * possible. Does not support null elements.
717 */ 727 */
718 public static interface FloatList extends ProtobufList<Float> { 728 public static interface FloatList extends ProtobufList<Float> {
719 729
720 /** 730 /**
721 * Like {@link #get(int)} but more efficient in that it doesn't box the retu rned value. 731 * Like {@link #get(int)} but more efficient in that it doesn't box the retu rned value.
722 */ 732 */
723 float getFloat(int index); 733 float getFloat(int index);
724 734
725 /** 735 /**
726 * Like {@link #add(Float)} but more efficient in that it doesn't box the el ement. 736 * Like {@link #add(Object)} but more efficient in that it doesn't box the e lement.
727 */ 737 */
728 void addFloat(float element); 738 void addFloat(float element);
729 739
730 /** 740 /**
731 * Like {@link #set(int, Float)} but more efficient in that it doesn't box t he element. 741 * Like {@link #set(int, Object)} but more efficient in that it doesn't box the element.
732 */ 742 */
733 float setFloat(int index, float element); 743 float setFloat(int index, float element);
734 744
735 /** 745 /**
736 * Returns a mutable clone of this list with the specified capacity. 746 * Returns a mutable clone of this list with the specified capacity.
737 */ 747 */
738 @Override 748 @Override
739 FloatList mutableCopyWithCapacity(int capacity); 749 FloatList mutableCopyWithCapacity(int capacity);
740 } 750 }
741 } 751 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698