美文网首页
api注释说明

api注释说明

作者: 萍水相逢_程序员 | 来源:发表于2018-09-27 10:41 被阅读0次

System下的 arraycopy

    /**
     *
     * @param src  源数组
     * @param srcPos  源数组复制的开始位置
     * @param dest   目标数组
     * @param destPos 目标数组放置的开始位置
     * @param length 复制的长度
     */
    public static void arraycopy(Object src,int srcPos,Object dest,int destPos,int length)

常在数组扩容和移动处使用

   public void expandCapacity(int minimumCapacity) {
        if (maxBufSize != -1 && minimumCapacity >= maxBufSize) {
            throw new JSONException("serialize exceeded MAX_OUTPUT_LENGTH=" + maxBufSize + ", minimumCapacity=" + minimumCapacity);
        }

        int newCapacity = buf.length + (buf.length >> 1) + 1;

        if (newCapacity < minimumCapacity) {
            newCapacity = minimumCapacity;
        }
        char newValue[] = new char[newCapacity];
        System.arraycopy(buf, 0, newValue, 0, count);
        buf = newValue;
    }

Class类中的 isInstance(Object obj)和isAssignableFrom(Class<?> cls)

判定类或者接口相同, 或者是指定的是是其超类或者超接口

public boolean isInstance(Object obj) {
        if (obj == null) {
            return false;
        }
        return isAssignableFrom(obj.getClass());
 }

public boolean isAssignableFrom(Class<?> cls) {
        if (this == cls) {
            return true;  // Can always assign to things of the same type.
        } else if (this == Object.class) {
            return !cls.isPrimitive();  // Can assign any reference to java.lang.Object.
        } else if (isArray()) {
            return cls.isArray() && componentType.isAssignableFrom(cls.componentType);
        } else if (isInterface()) {
            // Search iftable which has a flattened and uniqued list of interfaces.
            Object[] iftable = cls.ifTable;
            if (iftable != null) {
                for (int i = 0; i < iftable.length; i += 2) {
                    if (iftable[i] == this) {
                        return true;
                    }
                }
            }
            return false;
        } else {
            if (!cls.isInterface()) {
                for (cls = cls.superClass; cls != null; cls = cls.superClass) {
                    if (cls == this) {
                        return true;
                    }
                }
            }
            return false;
        }
    }


glide中使用

public class ImageViewTargetFactory {
  @NonNull
  @SuppressWarnings("unchecked")
  public <Z> ViewTarget<ImageView, Z> buildTarget(@NonNull ImageView view,
      @NonNull Class<Z> clazz) {
    if (Bitmap.class.equals(clazz)) {
      return (ViewTarget<ImageView, Z>) new BitmapImageViewTarget(view);
    } else if (Drawable.class.isAssignableFrom(clazz)) {
      return (ViewTarget<ImageView, Z>) new DrawableImageViewTarget(view);
    } else {
      throw new IllegalArgumentException(
          "Unhandled class: " + clazz + ", try .as*(Class).transcode(ResourceTranscoder)");
    }
  }
}

Java String类中的intern()

如果常量池中有一个String对象的字符串就返回池中的这个字符串的String对象;否则,将此String对象包含的字符串添加到常量池中去,并且返回此String对象的引用

   /**
     * Returns a canonical representation for the string object.
     * <p>
     * A pool of strings, initially empty, is maintained privately by the
     * class {@code String}.
     * <p>
     * When the intern method is invoked, if the pool already contains a
     * string equal to this {@code String} object as determined by
     * the {@link #equals(Object)} method, then the string from the pool is
     * returned. Otherwise, this {@code String} object is added to the
     * pool and a reference to this {@code String} object is returned.
     * <p>
     * It follows that for any two strings {@code s} and {@code t},
     * {@code s.intern() == t.intern()} is {@code true}
     * if and only if {@code s.equals(t)} is {@code true}.
     * <p>
     * All literal strings and string-valued constant expressions are
     * interned. String literals are defined in section 3.10.5 of the
     * <cite>The Java&trade; Language Specification</cite>.
     *
     * @return  a string that has the same contents as this string, but is
     *          guaranteed to be from a pool of unique strings.
     */
    @FastNative
    public native String intern();

相关文章

  • api注释说明

    System下的 arraycopy 常在数组扩容和移动处使用 Class类中的 isInstance(Objec...

  • Java - 注解

    对代码的说明 注释:给程序员看的。分为单行注释、多行注释和文档注释(用于生成API文档)。 注解:给计算机看的。最...

  • iOS-CGRect的一些扩展属性和方法

    下面是CGRect的苹果Api,我只注释说明一些常用的 publicvarminX:CGFloat{get} /...

  • Java根据文档注释生成API说明文档的方法

    注:API---说明文档这是一个有文档注释/** */的java代码: notepad++中鼠标右键---》选择...

  • Java基本语法

    注释:单行注释://[用一行注释对代码进行解释说明] 多行注释:/**/ [用多行注释对代码进行解释说明(注释一...

  • 【Axure10】说明(注释)区域-页面说明

    说明(注释)区域-页面说明 注:在预览时,显示注释说明内容需手动点击打开。 页面注释设置 编辑页面注释 进行页面注...

  • spring boot restful API风格

    下面我们尝试使用Spring MVC来实现一组对User对象操作的RESTful API,配合注释详细说明在Spr...

  • 注释说明-vue项目

    注释说明: 一. data属性说明: 【1】、单行属性,注释写在行尾good: bad: 【2】、多行属性,注释...

  • 流程控制语句

    注释:用于解释说明程序文字 分类:单行注释、多行注释 作用:解释说明程序,提高程序的阅读性 /* */多行注释 ...

  • ApiDoc 后端接口注释文档的使用

    前端和后端注释文档生成 前端和后端的 函数及api 说明文档生成总结,持续更新中 by Qzx 参考网址 jsD...

网友评论

      本文标题:api注释说明

      本文链接:https://www.haomeiwen.com/subject/urasoftx.html