集册 Java实例教程 提供的type元素的所有字段成员的便捷访问器。

提供的type元素的所有字段成员的便捷访问器。

欢马劈雪     最近更新时间:2020-01-02 10:19:05

375
提供的type元素的所有字段成员的便捷访问器。
/** 来自 时   代     Java  公  众  号 - nowjava.com**/

/**********************************************************************

Copyright (c) 2010 Andy Jefferson and others. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License");

you may not use this file except in compliance with the License.

You may obtain a copy of the License at


    http://www.apache.org/licenses/LICENSE-2.0


Unless required by applicable law or agreed to in writing, software

distributed under the License is distributed on an "AS IS" BASIS,

WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

See the License for the specific language governing permissions and

limitations under the License.


Contributors:

   ...

 **********************************************************************/

//package com.nowjava;

import java.util.ArrayList;


import java.util.Iterator;

import java.util.List;


import javax.lang.model.element.Element;

import javax.lang.model.element.ElementKind;


import javax.lang.model.element.TypeElement;


public class Main {

    /**

     * Convenience accessor for all field members of the supplied type element.

     * @param el The type element

     * @return The field members

     */

    public static List<? extends Element> getFieldMembers(TypeElement el) {

        List<? extends Element> members = el.getEnclosedElements();

        List<Element> fieldMembers = new ArrayList<Element>();

        Iterator<? extends Element> memberIter = members.iterator();

        while 
展开阅读全文