public function getFields($visibility = Field::VISIBILITY_PUBLIC)
    {
        $ret = [];
        foreach ($this->fields as $name => $field) {
            if ($field->getVisibility() & $visibility) {
                $ret[$name] = $field;
            }
        }
        return $ret;
    }