code: public String getResourceType() {
          if (resourceType == null) {
              resourceType = "";
              String type = resource.getResourceType();
              if (StringUtils.isBlank(type) || getPrimaryType().equals(type)) {
                  Resource contentResource = getContentResource();
                  if (contentResource != null) {
                      type = contentResource.getResourceType();
                      if (StringUtils.isNotBlank(type)) {
                          ResourceHandle handle = ResourceHandle.use(contentResource);
                          if (type.equals(handle.getPrimaryType())) {
                              type = null;
                          }
                      }
                  }
              }
              if (StringUtils.isNotBlank(type)) {
                  // check for a real existing resource type
                  if (!Resource.RESOURCE_TYPE_NON_EXISTING.equals(type)) {
                      resourceType = type;
                  }
              }
          }
          return resourceType;
      }
docs: the content resource type (sling:resourceType) declared for the current resource